mirror of
https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
synced 2025-09-08 17:18:05 -04:00
Fixed MTP to work with TWRP
This commit is contained in:
commit
f6dfaef42e
50820 changed files with 20846062 additions and 0 deletions
8
drivers/net/ethernet/amd/xgbe/Makefile
Normal file
8
drivers/net/ethernet/amd/xgbe/Makefile
Normal file
|
@ -0,0 +1,8 @@
|
|||
obj-$(CONFIG_AMD_XGBE) += amd-xgbe.o
|
||||
|
||||
amd-xgbe-objs := xgbe-main.o xgbe-drv.o xgbe-dev.o \
|
||||
xgbe-desc.o xgbe-ethtool.o xgbe-mdio.o \
|
||||
xgbe-ptp.o
|
||||
|
||||
amd-xgbe-$(CONFIG_AMD_XGBE_DCB) += xgbe-dcb.o
|
||||
amd-xgbe-$(CONFIG_DEBUG_FS) += xgbe-debugfs.o
|
1093
drivers/net/ethernet/amd/xgbe/xgbe-common.h
Normal file
1093
drivers/net/ethernet/amd/xgbe/xgbe-common.h
Normal file
File diff suppressed because it is too large
Load diff
269
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
Normal file
269
drivers/net/ethernet/amd/xgbe/xgbe-dcb.c
Normal file
|
@ -0,0 +1,269 @@
|
|||
/*
|
||||
* AMD 10Gb Ethernet driver
|
||||
*
|
||||
* This file is available to you under your choice of the following two
|
||||
* licenses:
|
||||
*
|
||||
* License 1: GPLv2
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* This file is free software; you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* License 2: Modified BSD
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
#include <net/dcbnl.h>
|
||||
|
||||
#include "xgbe.h"
|
||||
#include "xgbe-common.h"
|
||||
|
||||
static int xgbe_dcb_ieee_getets(struct net_device *netdev,
|
||||
struct ieee_ets *ets)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
|
||||
/* Set number of supported traffic classes */
|
||||
ets->ets_cap = pdata->hw_feat.tc_cnt;
|
||||
|
||||
if (pdata->ets) {
|
||||
ets->cbs = pdata->ets->cbs;
|
||||
memcpy(ets->tc_tx_bw, pdata->ets->tc_tx_bw,
|
||||
sizeof(ets->tc_tx_bw));
|
||||
memcpy(ets->tc_tsa, pdata->ets->tc_tsa,
|
||||
sizeof(ets->tc_tsa));
|
||||
memcpy(ets->prio_tc, pdata->ets->prio_tc,
|
||||
sizeof(ets->prio_tc));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_dcb_ieee_setets(struct net_device *netdev,
|
||||
struct ieee_ets *ets)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
unsigned int i, tc_ets, tc_ets_weight;
|
||||
|
||||
tc_ets = 0;
|
||||
tc_ets_weight = 0;
|
||||
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
|
||||
DBGPR(" TC%u: tx_bw=%hhu, rx_bw=%hhu, tsa=%hhu\n", i,
|
||||
ets->tc_tx_bw[i], ets->tc_rx_bw[i], ets->tc_tsa[i]);
|
||||
DBGPR(" PRIO%u: TC=%hhu\n", i, ets->prio_tc[i]);
|
||||
|
||||
if ((ets->tc_tx_bw[i] || ets->tc_tsa[i]) &&
|
||||
(i >= pdata->hw_feat.tc_cnt))
|
||||
return -EINVAL;
|
||||
|
||||
if (ets->prio_tc[i] >= pdata->hw_feat.tc_cnt)
|
||||
return -EINVAL;
|
||||
|
||||
switch (ets->tc_tsa[i]) {
|
||||
case IEEE_8021QAZ_TSA_STRICT:
|
||||
break;
|
||||
case IEEE_8021QAZ_TSA_ETS:
|
||||
tc_ets = 1;
|
||||
tc_ets_weight += ets->tc_tx_bw[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Weights must add up to 100% */
|
||||
if (tc_ets && (tc_ets_weight != 100))
|
||||
return -EINVAL;
|
||||
|
||||
if (!pdata->ets) {
|
||||
pdata->ets = devm_kzalloc(pdata->dev, sizeof(*pdata->ets),
|
||||
GFP_KERNEL);
|
||||
if (!pdata->ets)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(pdata->ets, ets, sizeof(*pdata->ets));
|
||||
|
||||
pdata->hw_if.config_dcb_tc(pdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_dcb_ieee_getpfc(struct net_device *netdev,
|
||||
struct ieee_pfc *pfc)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
|
||||
/* Set number of supported PFC traffic classes */
|
||||
pfc->pfc_cap = pdata->hw_feat.tc_cnt;
|
||||
|
||||
if (pdata->pfc) {
|
||||
pfc->pfc_en = pdata->pfc->pfc_en;
|
||||
pfc->mbc = pdata->pfc->mbc;
|
||||
pfc->delay = pdata->pfc->delay;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_dcb_ieee_setpfc(struct net_device *netdev,
|
||||
struct ieee_pfc *pfc)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
|
||||
DBGPR(" cap=%hhu, en=%hhx, mbc=%hhu, delay=%hhu\n",
|
||||
pfc->pfc_cap, pfc->pfc_en, pfc->mbc, pfc->delay);
|
||||
|
||||
if (!pdata->pfc) {
|
||||
pdata->pfc = devm_kzalloc(pdata->dev, sizeof(*pdata->pfc),
|
||||
GFP_KERNEL);
|
||||
if (!pdata->pfc)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(pdata->pfc, pfc, sizeof(*pdata->pfc));
|
||||
|
||||
pdata->hw_if.config_dcb_pfc(pdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u8 xgbe_dcb_getdcbx(struct net_device *netdev)
|
||||
{
|
||||
return DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE;
|
||||
}
|
||||
|
||||
static u8 xgbe_dcb_setdcbx(struct net_device *netdev, u8 dcbx)
|
||||
{
|
||||
u8 support = xgbe_dcb_getdcbx(netdev);
|
||||
|
||||
DBGPR(" DCBX=%#hhx\n", dcbx);
|
||||
|
||||
if (dcbx & ~support)
|
||||
return 1;
|
||||
|
||||
if ((dcbx & support) != support)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dcbnl_rtnl_ops xgbe_dcbnl_ops = {
|
||||
/* IEEE 802.1Qaz std */
|
||||
.ieee_getets = xgbe_dcb_ieee_getets,
|
||||
.ieee_setets = xgbe_dcb_ieee_setets,
|
||||
.ieee_getpfc = xgbe_dcb_ieee_getpfc,
|
||||
.ieee_setpfc = xgbe_dcb_ieee_setpfc,
|
||||
|
||||
/* DCBX configuration */
|
||||
.getdcbx = xgbe_dcb_getdcbx,
|
||||
.setdcbx = xgbe_dcb_setdcbx,
|
||||
};
|
||||
|
||||
const struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void)
|
||||
{
|
||||
return &xgbe_dcbnl_ops;
|
||||
}
|
373
drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
Normal file
373
drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
Normal file
|
@ -0,0 +1,373 @@
|
|||
/*
|
||||
* AMD 10Gb Ethernet driver
|
||||
*
|
||||
* This file is available to you under your choice of the following two
|
||||
* licenses:
|
||||
*
|
||||
* License 1: GPLv2
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* This file is free software; you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* License 2: Modified BSD
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "xgbe.h"
|
||||
#include "xgbe-common.h"
|
||||
|
||||
static ssize_t xgbe_common_read(char __user *buffer, size_t count,
|
||||
loff_t *ppos, unsigned int value)
|
||||
{
|
||||
char *buf;
|
||||
ssize_t len;
|
||||
|
||||
if (*ppos != 0)
|
||||
return 0;
|
||||
|
||||
buf = kasprintf(GFP_KERNEL, "0x%08x\n", value);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
if (count < strlen(buf)) {
|
||||
kfree(buf);
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
len = simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
|
||||
kfree(buf);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
|
||||
loff_t *ppos, unsigned int *value)
|
||||
{
|
||||
char workarea[32];
|
||||
ssize_t len;
|
||||
int ret;
|
||||
|
||||
if (*ppos != 0)
|
||||
return 0;
|
||||
|
||||
if (count >= sizeof(workarea))
|
||||
return -ENOSPC;
|
||||
|
||||
len = simple_write_to_buffer(workarea, sizeof(workarea) - 1, ppos,
|
||||
buffer, count);
|
||||
if (len < 0)
|
||||
return len;
|
||||
|
||||
workarea[len] = '\0';
|
||||
ret = kstrtouint(workarea, 16, value);
|
||||
if (ret)
|
||||
return -EIO;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static ssize_t xgmac_reg_addr_read(struct file *filp, char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
|
||||
return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xgmac_reg);
|
||||
}
|
||||
|
||||
static ssize_t xgmac_reg_addr_write(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
|
||||
return xgbe_common_write(buffer, count, ppos,
|
||||
&pdata->debugfs_xgmac_reg);
|
||||
}
|
||||
|
||||
static ssize_t xgmac_reg_value_read(struct file *filp, char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
unsigned int value;
|
||||
|
||||
value = XGMAC_IOREAD(pdata, pdata->debugfs_xgmac_reg);
|
||||
|
||||
return xgbe_common_read(buffer, count, ppos, value);
|
||||
}
|
||||
|
||||
static ssize_t xgmac_reg_value_write(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
unsigned int value;
|
||||
ssize_t len;
|
||||
|
||||
len = xgbe_common_write(buffer, count, ppos, &value);
|
||||
if (len < 0)
|
||||
return len;
|
||||
|
||||
XGMAC_IOWRITE(pdata, pdata->debugfs_xgmac_reg, value);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static const struct file_operations xgmac_reg_addr_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = simple_open,
|
||||
.read = xgmac_reg_addr_read,
|
||||
.write = xgmac_reg_addr_write,
|
||||
};
|
||||
|
||||
static const struct file_operations xgmac_reg_value_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = simple_open,
|
||||
.read = xgmac_reg_value_read,
|
||||
.write = xgmac_reg_value_write,
|
||||
};
|
||||
|
||||
static ssize_t xpcs_mmd_read(struct file *filp, char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
|
||||
return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xpcs_mmd);
|
||||
}
|
||||
|
||||
static ssize_t xpcs_mmd_write(struct file *filp, const char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
|
||||
return xgbe_common_write(buffer, count, ppos,
|
||||
&pdata->debugfs_xpcs_mmd);
|
||||
}
|
||||
|
||||
static ssize_t xpcs_reg_addr_read(struct file *filp, char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
|
||||
return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xpcs_reg);
|
||||
}
|
||||
|
||||
static ssize_t xpcs_reg_addr_write(struct file *filp, const char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
|
||||
return xgbe_common_write(buffer, count, ppos,
|
||||
&pdata->debugfs_xpcs_reg);
|
||||
}
|
||||
|
||||
static ssize_t xpcs_reg_value_read(struct file *filp, char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
unsigned int value;
|
||||
|
||||
value = XMDIO_READ(pdata, pdata->debugfs_xpcs_mmd,
|
||||
pdata->debugfs_xpcs_reg);
|
||||
|
||||
return xgbe_common_read(buffer, count, ppos, value);
|
||||
}
|
||||
|
||||
static ssize_t xpcs_reg_value_write(struct file *filp,
|
||||
const char __user *buffer,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = filp->private_data;
|
||||
unsigned int value;
|
||||
ssize_t len;
|
||||
|
||||
len = xgbe_common_write(buffer, count, ppos, &value);
|
||||
if (len < 0)
|
||||
return len;
|
||||
|
||||
XMDIO_WRITE(pdata, pdata->debugfs_xpcs_mmd, pdata->debugfs_xpcs_reg,
|
||||
value);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static const struct file_operations xpcs_mmd_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = simple_open,
|
||||
.read = xpcs_mmd_read,
|
||||
.write = xpcs_mmd_write,
|
||||
};
|
||||
|
||||
static const struct file_operations xpcs_reg_addr_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = simple_open,
|
||||
.read = xpcs_reg_addr_read,
|
||||
.write = xpcs_reg_addr_write,
|
||||
};
|
||||
|
||||
static const struct file_operations xpcs_reg_value_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = simple_open,
|
||||
.read = xpcs_reg_value_read,
|
||||
.write = xpcs_reg_value_write,
|
||||
};
|
||||
|
||||
void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct dentry *pfile;
|
||||
char *buf;
|
||||
|
||||
/* Set defaults */
|
||||
pdata->debugfs_xgmac_reg = 0;
|
||||
pdata->debugfs_xpcs_mmd = 1;
|
||||
pdata->debugfs_xpcs_reg = 0;
|
||||
|
||||
buf = kasprintf(GFP_KERNEL, "amd-xgbe-%s", pdata->netdev->name);
|
||||
pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL);
|
||||
if (pdata->xgbe_debugfs == NULL) {
|
||||
netdev_err(pdata->netdev, "debugfs_create_dir failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pfile = debugfs_create_file("xgmac_register", 0600,
|
||||
pdata->xgbe_debugfs, pdata,
|
||||
&xgmac_reg_addr_fops);
|
||||
if (!pfile)
|
||||
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
|
||||
|
||||
pfile = debugfs_create_file("xgmac_register_value", 0600,
|
||||
pdata->xgbe_debugfs, pdata,
|
||||
&xgmac_reg_value_fops);
|
||||
if (!pfile)
|
||||
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
|
||||
|
||||
pfile = debugfs_create_file("xpcs_mmd", 0600,
|
||||
pdata->xgbe_debugfs, pdata,
|
||||
&xpcs_mmd_fops);
|
||||
if (!pfile)
|
||||
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
|
||||
|
||||
pfile = debugfs_create_file("xpcs_register", 0600,
|
||||
pdata->xgbe_debugfs, pdata,
|
||||
&xpcs_reg_addr_fops);
|
||||
if (!pfile)
|
||||
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
|
||||
|
||||
pfile = debugfs_create_file("xpcs_register_value", 0600,
|
||||
pdata->xgbe_debugfs, pdata,
|
||||
&xpcs_reg_value_fops);
|
||||
if (!pfile)
|
||||
netdev_err(pdata->netdev, "debugfs_create_file failed\n");
|
||||
|
||||
kfree(buf);
|
||||
}
|
||||
|
||||
void xgbe_debugfs_exit(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
debugfs_remove_recursive(pdata->xgbe_debugfs);
|
||||
pdata->xgbe_debugfs = NULL;
|
||||
}
|
562
drivers/net/ethernet/amd/xgbe/xgbe-desc.c
Normal file
562
drivers/net/ethernet/amd/xgbe/xgbe-desc.c
Normal file
|
@ -0,0 +1,562 @@
|
|||
/*
|
||||
* AMD 10Gb Ethernet driver
|
||||
*
|
||||
* This file is available to you under your choice of the following two
|
||||
* licenses:
|
||||
*
|
||||
* License 1: GPLv2
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* This file is free software; you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* License 2: Modified BSD
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xgbe.h"
|
||||
#include "xgbe-common.h"
|
||||
|
||||
static void xgbe_unmap_skb(struct xgbe_prv_data *, struct xgbe_ring_data *);
|
||||
|
||||
static void xgbe_free_ring(struct xgbe_prv_data *pdata,
|
||||
struct xgbe_ring *ring)
|
||||
{
|
||||
struct xgbe_ring_data *rdata;
|
||||
unsigned int i;
|
||||
|
||||
if (!ring)
|
||||
return;
|
||||
|
||||
if (ring->rdata) {
|
||||
for (i = 0; i < ring->rdesc_count; i++) {
|
||||
rdata = XGBE_GET_DESC_DATA(ring, i);
|
||||
xgbe_unmap_skb(pdata, rdata);
|
||||
}
|
||||
|
||||
kfree(ring->rdata);
|
||||
ring->rdata = NULL;
|
||||
}
|
||||
|
||||
if (ring->rdesc) {
|
||||
dma_free_coherent(pdata->dev,
|
||||
(sizeof(struct xgbe_ring_desc) *
|
||||
ring->rdesc_count),
|
||||
ring->rdesc, ring->rdesc_dma);
|
||||
ring->rdesc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void xgbe_free_ring_resources(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct xgbe_channel *channel;
|
||||
unsigned int i;
|
||||
|
||||
DBGPR("-->xgbe_free_ring_resources\n");
|
||||
|
||||
channel = pdata->channel;
|
||||
for (i = 0; i < pdata->channel_count; i++, channel++) {
|
||||
xgbe_free_ring(pdata, channel->tx_ring);
|
||||
xgbe_free_ring(pdata, channel->rx_ring);
|
||||
}
|
||||
|
||||
DBGPR("<--xgbe_free_ring_resources\n");
|
||||
}
|
||||
|
||||
static int xgbe_init_ring(struct xgbe_prv_data *pdata,
|
||||
struct xgbe_ring *ring, unsigned int rdesc_count)
|
||||
{
|
||||
DBGPR("-->xgbe_init_ring\n");
|
||||
|
||||
if (!ring)
|
||||
return 0;
|
||||
|
||||
/* Descriptors */
|
||||
ring->rdesc_count = rdesc_count;
|
||||
ring->rdesc = dma_alloc_coherent(pdata->dev,
|
||||
(sizeof(struct xgbe_ring_desc) *
|
||||
rdesc_count), &ring->rdesc_dma,
|
||||
GFP_KERNEL);
|
||||
if (!ring->rdesc)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Descriptor information */
|
||||
ring->rdata = kcalloc(rdesc_count, sizeof(struct xgbe_ring_data),
|
||||
GFP_KERNEL);
|
||||
if (!ring->rdata)
|
||||
return -ENOMEM;
|
||||
|
||||
DBGPR(" rdesc=0x%p, rdesc_dma=0x%llx, rdata=0x%p\n",
|
||||
ring->rdesc, ring->rdesc_dma, ring->rdata);
|
||||
|
||||
DBGPR("<--xgbe_init_ring\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_alloc_ring_resources(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct xgbe_channel *channel;
|
||||
unsigned int i;
|
||||
int ret;
|
||||
|
||||
DBGPR("-->xgbe_alloc_ring_resources\n");
|
||||
|
||||
channel = pdata->channel;
|
||||
for (i = 0; i < pdata->channel_count; i++, channel++) {
|
||||
DBGPR(" %s - tx_ring:\n", channel->name);
|
||||
ret = xgbe_init_ring(pdata, channel->tx_ring,
|
||||
pdata->tx_desc_count);
|
||||
if (ret) {
|
||||
netdev_alert(pdata->netdev,
|
||||
"error initializing Tx ring\n");
|
||||
goto err_ring;
|
||||
}
|
||||
|
||||
DBGPR(" %s - rx_ring:\n", channel->name);
|
||||
ret = xgbe_init_ring(pdata, channel->rx_ring,
|
||||
pdata->rx_desc_count);
|
||||
if (ret) {
|
||||
netdev_alert(pdata->netdev,
|
||||
"error initializing Tx ring\n");
|
||||
goto err_ring;
|
||||
}
|
||||
}
|
||||
|
||||
DBGPR("<--xgbe_alloc_ring_resources\n");
|
||||
|
||||
return 0;
|
||||
|
||||
err_ring:
|
||||
xgbe_free_ring_resources(pdata);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void xgbe_wrapper_tx_descriptor_init(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct xgbe_hw_if *hw_if = &pdata->hw_if;
|
||||
struct xgbe_channel *channel;
|
||||
struct xgbe_ring *ring;
|
||||
struct xgbe_ring_data *rdata;
|
||||
struct xgbe_ring_desc *rdesc;
|
||||
dma_addr_t rdesc_dma;
|
||||
unsigned int i, j;
|
||||
|
||||
DBGPR("-->xgbe_wrapper_tx_descriptor_init\n");
|
||||
|
||||
channel = pdata->channel;
|
||||
for (i = 0; i < pdata->channel_count; i++, channel++) {
|
||||
ring = channel->tx_ring;
|
||||
if (!ring)
|
||||
break;
|
||||
|
||||
rdesc = ring->rdesc;
|
||||
rdesc_dma = ring->rdesc_dma;
|
||||
|
||||
for (j = 0; j < ring->rdesc_count; j++) {
|
||||
rdata = XGBE_GET_DESC_DATA(ring, j);
|
||||
|
||||
rdata->rdesc = rdesc;
|
||||
rdata->rdesc_dma = rdesc_dma;
|
||||
|
||||
rdesc++;
|
||||
rdesc_dma += sizeof(struct xgbe_ring_desc);
|
||||
}
|
||||
|
||||
ring->cur = 0;
|
||||
ring->dirty = 0;
|
||||
ring->tx.queue_stopped = 0;
|
||||
|
||||
hw_if->tx_desc_init(channel);
|
||||
}
|
||||
|
||||
DBGPR("<--xgbe_wrapper_tx_descriptor_init\n");
|
||||
}
|
||||
|
||||
static void xgbe_wrapper_rx_descriptor_init(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct xgbe_hw_if *hw_if = &pdata->hw_if;
|
||||
struct xgbe_channel *channel;
|
||||
struct xgbe_ring *ring;
|
||||
struct xgbe_ring_desc *rdesc;
|
||||
struct xgbe_ring_data *rdata;
|
||||
dma_addr_t rdesc_dma, skb_dma;
|
||||
struct sk_buff *skb = NULL;
|
||||
unsigned int i, j;
|
||||
|
||||
DBGPR("-->xgbe_wrapper_rx_descriptor_init\n");
|
||||
|
||||
channel = pdata->channel;
|
||||
for (i = 0; i < pdata->channel_count; i++, channel++) {
|
||||
ring = channel->rx_ring;
|
||||
if (!ring)
|
||||
break;
|
||||
|
||||
rdesc = ring->rdesc;
|
||||
rdesc_dma = ring->rdesc_dma;
|
||||
|
||||
for (j = 0; j < ring->rdesc_count; j++) {
|
||||
rdata = XGBE_GET_DESC_DATA(ring, j);
|
||||
|
||||
rdata->rdesc = rdesc;
|
||||
rdata->rdesc_dma = rdesc_dma;
|
||||
|
||||
/* Allocate skb & assign to each rdesc */
|
||||
skb = dev_alloc_skb(pdata->rx_buf_size);
|
||||
if (skb == NULL)
|
||||
break;
|
||||
skb_dma = dma_map_single(pdata->dev, skb->data,
|
||||
pdata->rx_buf_size,
|
||||
DMA_FROM_DEVICE);
|
||||
if (dma_mapping_error(pdata->dev, skb_dma)) {
|
||||
netdev_alert(pdata->netdev,
|
||||
"failed to do the dma map\n");
|
||||
dev_kfree_skb_any(skb);
|
||||
break;
|
||||
}
|
||||
rdata->skb = skb;
|
||||
rdata->skb_dma = skb_dma;
|
||||
rdata->skb_dma_len = pdata->rx_buf_size;
|
||||
|
||||
rdesc++;
|
||||
rdesc_dma += sizeof(struct xgbe_ring_desc);
|
||||
}
|
||||
|
||||
ring->cur = 0;
|
||||
ring->dirty = 0;
|
||||
ring->rx.realloc_index = 0;
|
||||
ring->rx.realloc_threshold = 0;
|
||||
|
||||
hw_if->rx_desc_init(channel);
|
||||
}
|
||||
|
||||
DBGPR("<--xgbe_wrapper_rx_descriptor_init\n");
|
||||
}
|
||||
|
||||
static void xgbe_unmap_skb(struct xgbe_prv_data *pdata,
|
||||
struct xgbe_ring_data *rdata)
|
||||
{
|
||||
if (rdata->skb_dma) {
|
||||
if (rdata->mapped_as_page) {
|
||||
dma_unmap_page(pdata->dev, rdata->skb_dma,
|
||||
rdata->skb_dma_len, DMA_TO_DEVICE);
|
||||
} else {
|
||||
dma_unmap_single(pdata->dev, rdata->skb_dma,
|
||||
rdata->skb_dma_len, DMA_TO_DEVICE);
|
||||
}
|
||||
rdata->skb_dma = 0;
|
||||
rdata->skb_dma_len = 0;
|
||||
}
|
||||
|
||||
if (rdata->skb) {
|
||||
dev_kfree_skb_any(rdata->skb);
|
||||
rdata->skb = NULL;
|
||||
}
|
||||
|
||||
rdata->tso_header = 0;
|
||||
rdata->len = 0;
|
||||
rdata->interrupt = 0;
|
||||
rdata->mapped_as_page = 0;
|
||||
|
||||
if (rdata->state_saved) {
|
||||
rdata->state_saved = 0;
|
||||
rdata->state.incomplete = 0;
|
||||
rdata->state.context_next = 0;
|
||||
rdata->state.skb = NULL;
|
||||
rdata->state.len = 0;
|
||||
rdata->state.error = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = channel->pdata;
|
||||
struct xgbe_ring *ring = channel->tx_ring;
|
||||
struct xgbe_ring_data *rdata;
|
||||
struct xgbe_packet_data *packet;
|
||||
struct skb_frag_struct *frag;
|
||||
dma_addr_t skb_dma;
|
||||
unsigned int start_index, cur_index;
|
||||
unsigned int offset, tso, vlan, datalen, len;
|
||||
unsigned int i;
|
||||
|
||||
DBGPR("-->xgbe_map_tx_skb: cur = %d\n", ring->cur);
|
||||
|
||||
offset = 0;
|
||||
start_index = ring->cur;
|
||||
cur_index = ring->cur;
|
||||
|
||||
packet = &ring->packet_data;
|
||||
packet->rdesc_count = 0;
|
||||
packet->length = 0;
|
||||
|
||||
tso = XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES,
|
||||
TSO_ENABLE);
|
||||
vlan = XGMAC_GET_BITS(packet->attributes, TX_PACKET_ATTRIBUTES,
|
||||
VLAN_CTAG);
|
||||
|
||||
/* Save space for a context descriptor if needed */
|
||||
if ((tso && (packet->mss != ring->tx.cur_mss)) ||
|
||||
(vlan && (packet->vlan_ctag != ring->tx.cur_vlan_ctag)))
|
||||
cur_index++;
|
||||
rdata = XGBE_GET_DESC_DATA(ring, cur_index);
|
||||
|
||||
if (tso) {
|
||||
DBGPR(" TSO packet\n");
|
||||
|
||||
/* Map the TSO header */
|
||||
skb_dma = dma_map_single(pdata->dev, skb->data,
|
||||
packet->header_len, DMA_TO_DEVICE);
|
||||
if (dma_mapping_error(pdata->dev, skb_dma)) {
|
||||
netdev_alert(pdata->netdev, "dma_map_single failed\n");
|
||||
goto err_out;
|
||||
}
|
||||
rdata->skb_dma = skb_dma;
|
||||
rdata->skb_dma_len = packet->header_len;
|
||||
rdata->tso_header = 1;
|
||||
|
||||
offset = packet->header_len;
|
||||
|
||||
packet->length += packet->header_len;
|
||||
|
||||
cur_index++;
|
||||
rdata = XGBE_GET_DESC_DATA(ring, cur_index);
|
||||
}
|
||||
|
||||
/* Map the (remainder of the) packet */
|
||||
for (datalen = skb_headlen(skb) - offset; datalen; ) {
|
||||
len = min_t(unsigned int, datalen, XGBE_TX_MAX_BUF_SIZE);
|
||||
|
||||
skb_dma = dma_map_single(pdata->dev, skb->data + offset, len,
|
||||
DMA_TO_DEVICE);
|
||||
if (dma_mapping_error(pdata->dev, skb_dma)) {
|
||||
netdev_alert(pdata->netdev, "dma_map_single failed\n");
|
||||
goto err_out;
|
||||
}
|
||||
rdata->skb_dma = skb_dma;
|
||||
rdata->skb_dma_len = len;
|
||||
DBGPR(" skb data: index=%u, dma=0x%llx, len=%u\n",
|
||||
cur_index, skb_dma, len);
|
||||
|
||||
datalen -= len;
|
||||
offset += len;
|
||||
|
||||
packet->length += len;
|
||||
|
||||
cur_index++;
|
||||
rdata = XGBE_GET_DESC_DATA(ring, cur_index);
|
||||
}
|
||||
|
||||
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
|
||||
DBGPR(" mapping frag %u\n", i);
|
||||
|
||||
frag = &skb_shinfo(skb)->frags[i];
|
||||
offset = 0;
|
||||
|
||||
for (datalen = skb_frag_size(frag); datalen; ) {
|
||||
len = min_t(unsigned int, datalen,
|
||||
XGBE_TX_MAX_BUF_SIZE);
|
||||
|
||||
skb_dma = skb_frag_dma_map(pdata->dev, frag, offset,
|
||||
len, DMA_TO_DEVICE);
|
||||
if (dma_mapping_error(pdata->dev, skb_dma)) {
|
||||
netdev_alert(pdata->netdev,
|
||||
"skb_frag_dma_map failed\n");
|
||||
goto err_out;
|
||||
}
|
||||
rdata->skb_dma = skb_dma;
|
||||
rdata->skb_dma_len = len;
|
||||
rdata->mapped_as_page = 1;
|
||||
DBGPR(" skb data: index=%u, dma=0x%llx, len=%u\n",
|
||||
cur_index, skb_dma, len);
|
||||
|
||||
datalen -= len;
|
||||
offset += len;
|
||||
|
||||
packet->length += len;
|
||||
|
||||
cur_index++;
|
||||
rdata = XGBE_GET_DESC_DATA(ring, cur_index);
|
||||
}
|
||||
}
|
||||
|
||||
/* Save the skb address in the last entry */
|
||||
rdata->skb = skb;
|
||||
|
||||
/* Save the number of descriptor entries used */
|
||||
packet->rdesc_count = cur_index - start_index;
|
||||
|
||||
DBGPR("<--xgbe_map_tx_skb: count=%u\n", packet->rdesc_count);
|
||||
|
||||
return packet->rdesc_count;
|
||||
|
||||
err_out:
|
||||
while (start_index < cur_index) {
|
||||
rdata = XGBE_GET_DESC_DATA(ring, start_index++);
|
||||
xgbe_unmap_skb(pdata, rdata);
|
||||
}
|
||||
|
||||
DBGPR("<--xgbe_map_tx_skb: count=0\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void xgbe_realloc_skb(struct xgbe_channel *channel)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = channel->pdata;
|
||||
struct xgbe_hw_if *hw_if = &pdata->hw_if;
|
||||
struct xgbe_ring *ring = channel->rx_ring;
|
||||
struct xgbe_ring_data *rdata;
|
||||
struct sk_buff *skb = NULL;
|
||||
dma_addr_t skb_dma;
|
||||
int i;
|
||||
|
||||
DBGPR("-->xgbe_realloc_skb: rx_ring->rx.realloc_index = %u\n",
|
||||
ring->rx.realloc_index);
|
||||
|
||||
for (i = 0; i < ring->dirty; i++) {
|
||||
rdata = XGBE_GET_DESC_DATA(ring, ring->rx.realloc_index);
|
||||
|
||||
/* Reset rdata values */
|
||||
xgbe_unmap_skb(pdata, rdata);
|
||||
|
||||
/* Allocate skb & assign to each rdesc */
|
||||
skb = dev_alloc_skb(pdata->rx_buf_size);
|
||||
if (skb == NULL)
|
||||
break;
|
||||
skb_dma = dma_map_single(pdata->dev, skb->data,
|
||||
pdata->rx_buf_size, DMA_FROM_DEVICE);
|
||||
if (dma_mapping_error(pdata->dev, skb_dma)) {
|
||||
netdev_alert(pdata->netdev,
|
||||
"failed to do the dma map\n");
|
||||
dev_kfree_skb_any(skb);
|
||||
break;
|
||||
}
|
||||
rdata->skb = skb;
|
||||
rdata->skb_dma = skb_dma;
|
||||
rdata->skb_dma_len = pdata->rx_buf_size;
|
||||
|
||||
hw_if->rx_desc_reset(rdata);
|
||||
|
||||
ring->rx.realloc_index++;
|
||||
}
|
||||
ring->dirty = 0;
|
||||
|
||||
DBGPR("<--xgbe_realloc_skb\n");
|
||||
}
|
||||
|
||||
void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *desc_if)
|
||||
{
|
||||
DBGPR("-->xgbe_init_function_ptrs_desc\n");
|
||||
|
||||
desc_if->alloc_ring_resources = xgbe_alloc_ring_resources;
|
||||
desc_if->free_ring_resources = xgbe_free_ring_resources;
|
||||
desc_if->map_tx_skb = xgbe_map_tx_skb;
|
||||
desc_if->realloc_skb = xgbe_realloc_skb;
|
||||
desc_if->unmap_skb = xgbe_unmap_skb;
|
||||
desc_if->wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init;
|
||||
desc_if->wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init;
|
||||
|
||||
DBGPR("<--xgbe_init_function_ptrs_desc\n");
|
||||
}
|
2624
drivers/net/ethernet/amd/xgbe/xgbe-dev.c
Normal file
2624
drivers/net/ethernet/amd/xgbe/xgbe-dev.c
Normal file
File diff suppressed because it is too large
Load diff
1865
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
Normal file
1865
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
Normal file
File diff suppressed because it is too large
Load diff
535
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
Normal file
535
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
Normal file
|
@ -0,0 +1,535 @@
|
|||
/*
|
||||
* AMD 10Gb Ethernet driver
|
||||
*
|
||||
* This file is available to you under your choice of the following two
|
||||
* licenses:
|
||||
*
|
||||
* License 1: GPLv2
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* This file is free software; you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* License 2: Modified BSD
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/phy.h>
|
||||
#include <linux/net_tstamp.h>
|
||||
|
||||
#include "xgbe.h"
|
||||
#include "xgbe-common.h"
|
||||
|
||||
struct xgbe_stats {
|
||||
char stat_string[ETH_GSTRING_LEN];
|
||||
int stat_size;
|
||||
int stat_offset;
|
||||
};
|
||||
|
||||
#define XGMAC_MMC_STAT(_string, _var) \
|
||||
{ _string, \
|
||||
FIELD_SIZEOF(struct xgbe_mmc_stats, _var), \
|
||||
offsetof(struct xgbe_prv_data, mmc_stats._var), \
|
||||
}
|
||||
|
||||
static const struct xgbe_stats xgbe_gstring_stats[] = {
|
||||
XGMAC_MMC_STAT("tx_bytes", txoctetcount_gb),
|
||||
XGMAC_MMC_STAT("tx_packets", txframecount_gb),
|
||||
XGMAC_MMC_STAT("tx_unicast_packets", txunicastframes_gb),
|
||||
XGMAC_MMC_STAT("tx_broadcast_packets", txbroadcastframes_gb),
|
||||
XGMAC_MMC_STAT("tx_multicast_packets", txmulticastframes_gb),
|
||||
XGMAC_MMC_STAT("tx_vlan_packets", txvlanframes_g),
|
||||
XGMAC_MMC_STAT("tx_64_byte_packets", tx64octets_gb),
|
||||
XGMAC_MMC_STAT("tx_65_to_127_byte_packets", tx65to127octets_gb),
|
||||
XGMAC_MMC_STAT("tx_128_to_255_byte_packets", tx128to255octets_gb),
|
||||
XGMAC_MMC_STAT("tx_256_to_511_byte_packets", tx256to511octets_gb),
|
||||
XGMAC_MMC_STAT("tx_512_to_1023_byte_packets", tx512to1023octets_gb),
|
||||
XGMAC_MMC_STAT("tx_1024_to_max_byte_packets", tx1024tomaxoctets_gb),
|
||||
XGMAC_MMC_STAT("tx_underflow_errors", txunderflowerror),
|
||||
XGMAC_MMC_STAT("tx_pause_frames", txpauseframes),
|
||||
|
||||
XGMAC_MMC_STAT("rx_bytes", rxoctetcount_gb),
|
||||
XGMAC_MMC_STAT("rx_packets", rxframecount_gb),
|
||||
XGMAC_MMC_STAT("rx_unicast_packets", rxunicastframes_g),
|
||||
XGMAC_MMC_STAT("rx_broadcast_packets", rxbroadcastframes_g),
|
||||
XGMAC_MMC_STAT("rx_multicast_packets", rxmulticastframes_g),
|
||||
XGMAC_MMC_STAT("rx_vlan_packets", rxvlanframes_gb),
|
||||
XGMAC_MMC_STAT("rx_64_byte_packets", rx64octets_gb),
|
||||
XGMAC_MMC_STAT("rx_65_to_127_byte_packets", rx65to127octets_gb),
|
||||
XGMAC_MMC_STAT("rx_128_to_255_byte_packets", rx128to255octets_gb),
|
||||
XGMAC_MMC_STAT("rx_256_to_511_byte_packets", rx256to511octets_gb),
|
||||
XGMAC_MMC_STAT("rx_512_to_1023_byte_packets", rx512to1023octets_gb),
|
||||
XGMAC_MMC_STAT("rx_1024_to_max_byte_packets", rx1024tomaxoctets_gb),
|
||||
XGMAC_MMC_STAT("rx_undersize_packets", rxundersize_g),
|
||||
XGMAC_MMC_STAT("rx_oversize_packets", rxoversize_g),
|
||||
XGMAC_MMC_STAT("rx_crc_errors", rxcrcerror),
|
||||
XGMAC_MMC_STAT("rx_crc_errors_small_packets", rxrunterror),
|
||||
XGMAC_MMC_STAT("rx_crc_errors_giant_packets", rxjabbererror),
|
||||
XGMAC_MMC_STAT("rx_length_errors", rxlengtherror),
|
||||
XGMAC_MMC_STAT("rx_out_of_range_errors", rxoutofrangetype),
|
||||
XGMAC_MMC_STAT("rx_fifo_overflow_errors", rxfifooverflow),
|
||||
XGMAC_MMC_STAT("rx_watchdog_errors", rxwatchdogerror),
|
||||
XGMAC_MMC_STAT("rx_pause_frames", rxpauseframes),
|
||||
};
|
||||
|
||||
#define XGBE_STATS_COUNT ARRAY_SIZE(xgbe_gstring_stats)
|
||||
|
||||
static void xgbe_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
|
||||
{
|
||||
int i;
|
||||
|
||||
DBGPR("-->%s\n", __func__);
|
||||
|
||||
switch (stringset) {
|
||||
case ETH_SS_STATS:
|
||||
for (i = 0; i < XGBE_STATS_COUNT; i++) {
|
||||
memcpy(data, xgbe_gstring_stats[i].stat_string,
|
||||
ETH_GSTRING_LEN);
|
||||
data += ETH_GSTRING_LEN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
DBGPR("<--%s\n", __func__);
|
||||
}
|
||||
|
||||
static void xgbe_get_ethtool_stats(struct net_device *netdev,
|
||||
struct ethtool_stats *stats, u64 *data)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
u8 *stat;
|
||||
int i;
|
||||
|
||||
DBGPR("-->%s\n", __func__);
|
||||
|
||||
pdata->hw_if.read_mmc_stats(pdata);
|
||||
for (i = 0; i < XGBE_STATS_COUNT; i++) {
|
||||
stat = (u8 *)pdata + xgbe_gstring_stats[i].stat_offset;
|
||||
*data++ = *(u64 *)stat;
|
||||
}
|
||||
|
||||
DBGPR("<--%s\n", __func__);
|
||||
}
|
||||
|
||||
static int xgbe_get_sset_count(struct net_device *netdev, int stringset)
|
||||
{
|
||||
int ret;
|
||||
|
||||
DBGPR("-->%s\n", __func__);
|
||||
|
||||
switch (stringset) {
|
||||
case ETH_SS_STATS:
|
||||
ret = XGBE_STATS_COUNT;
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
DBGPR("<--%s\n", __func__);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void xgbe_get_pauseparam(struct net_device *netdev,
|
||||
struct ethtool_pauseparam *pause)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
|
||||
DBGPR("-->xgbe_get_pauseparam\n");
|
||||
|
||||
pause->autoneg = pdata->pause_autoneg;
|
||||
pause->tx_pause = pdata->tx_pause;
|
||||
pause->rx_pause = pdata->rx_pause;
|
||||
|
||||
DBGPR("<--xgbe_get_pauseparam\n");
|
||||
}
|
||||
|
||||
static int xgbe_set_pauseparam(struct net_device *netdev,
|
||||
struct ethtool_pauseparam *pause)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
struct phy_device *phydev = pdata->phydev;
|
||||
int ret = 0;
|
||||
|
||||
DBGPR("-->xgbe_set_pauseparam\n");
|
||||
|
||||
DBGPR(" autoneg = %d, tx_pause = %d, rx_pause = %d\n",
|
||||
pause->autoneg, pause->tx_pause, pause->rx_pause);
|
||||
|
||||
pdata->pause_autoneg = pause->autoneg;
|
||||
if (pause->autoneg) {
|
||||
phydev->advertising |= ADVERTISED_Pause;
|
||||
phydev->advertising |= ADVERTISED_Asym_Pause;
|
||||
|
||||
} else {
|
||||
phydev->advertising &= ~ADVERTISED_Pause;
|
||||
phydev->advertising &= ~ADVERTISED_Asym_Pause;
|
||||
|
||||
pdata->tx_pause = pause->tx_pause;
|
||||
pdata->rx_pause = pause->rx_pause;
|
||||
}
|
||||
|
||||
if (netif_running(netdev))
|
||||
ret = phy_start_aneg(phydev);
|
||||
|
||||
DBGPR("<--xgbe_set_pauseparam\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int xgbe_get_settings(struct net_device *netdev,
|
||||
struct ethtool_cmd *cmd)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
int ret;
|
||||
|
||||
DBGPR("-->xgbe_get_settings\n");
|
||||
|
||||
if (!pdata->phydev)
|
||||
return -ENODEV;
|
||||
|
||||
ret = phy_ethtool_gset(pdata->phydev, cmd);
|
||||
cmd->transceiver = XCVR_EXTERNAL;
|
||||
|
||||
DBGPR("<--xgbe_get_settings\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int xgbe_set_settings(struct net_device *netdev,
|
||||
struct ethtool_cmd *cmd)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
struct phy_device *phydev = pdata->phydev;
|
||||
u32 speed;
|
||||
int ret;
|
||||
|
||||
DBGPR("-->xgbe_set_settings\n");
|
||||
|
||||
if (!pdata->phydev)
|
||||
return -ENODEV;
|
||||
|
||||
speed = ethtool_cmd_speed(cmd);
|
||||
|
||||
if (cmd->phy_address != phydev->addr)
|
||||
return -EINVAL;
|
||||
|
||||
if ((cmd->autoneg != AUTONEG_ENABLE) &&
|
||||
(cmd->autoneg != AUTONEG_DISABLE))
|
||||
return -EINVAL;
|
||||
|
||||
if (cmd->autoneg == AUTONEG_DISABLE) {
|
||||
switch (speed) {
|
||||
case SPEED_10000:
|
||||
case SPEED_2500:
|
||||
case SPEED_1000:
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (cmd->duplex != DUPLEX_FULL)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cmd->advertising &= phydev->supported;
|
||||
if ((cmd->autoneg == AUTONEG_ENABLE) && !cmd->advertising)
|
||||
return -EINVAL;
|
||||
|
||||
ret = 0;
|
||||
phydev->autoneg = cmd->autoneg;
|
||||
phydev->speed = speed;
|
||||
phydev->duplex = cmd->duplex;
|
||||
phydev->advertising = cmd->advertising;
|
||||
|
||||
if (cmd->autoneg == AUTONEG_ENABLE)
|
||||
phydev->advertising |= ADVERTISED_Autoneg;
|
||||
else
|
||||
phydev->advertising &= ~ADVERTISED_Autoneg;
|
||||
|
||||
if (netif_running(netdev))
|
||||
ret = phy_start_aneg(phydev);
|
||||
|
||||
DBGPR("<--xgbe_set_settings\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void xgbe_get_drvinfo(struct net_device *netdev,
|
||||
struct ethtool_drvinfo *drvinfo)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
struct xgbe_hw_features *hw_feat = &pdata->hw_feat;
|
||||
|
||||
strlcpy(drvinfo->driver, XGBE_DRV_NAME, sizeof(drvinfo->driver));
|
||||
strlcpy(drvinfo->version, XGBE_DRV_VERSION, sizeof(drvinfo->version));
|
||||
strlcpy(drvinfo->bus_info, dev_name(pdata->dev),
|
||||
sizeof(drvinfo->bus_info));
|
||||
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d.%d.%d",
|
||||
XGMAC_GET_BITS(hw_feat->version, MAC_VR, USERVER),
|
||||
XGMAC_GET_BITS(hw_feat->version, MAC_VR, DEVID),
|
||||
XGMAC_GET_BITS(hw_feat->version, MAC_VR, SNPSVER));
|
||||
drvinfo->n_stats = XGBE_STATS_COUNT;
|
||||
}
|
||||
|
||||
static int xgbe_get_coalesce(struct net_device *netdev,
|
||||
struct ethtool_coalesce *ec)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
struct xgbe_hw_if *hw_if = &pdata->hw_if;
|
||||
unsigned int riwt;
|
||||
|
||||
DBGPR("-->xgbe_get_coalesce\n");
|
||||
|
||||
memset(ec, 0, sizeof(struct ethtool_coalesce));
|
||||
|
||||
riwt = pdata->rx_riwt;
|
||||
ec->rx_coalesce_usecs = hw_if->riwt_to_usec(pdata, riwt);
|
||||
ec->rx_max_coalesced_frames = pdata->rx_frames;
|
||||
|
||||
ec->tx_coalesce_usecs = pdata->tx_usecs;
|
||||
ec->tx_max_coalesced_frames = pdata->tx_frames;
|
||||
|
||||
DBGPR("<--xgbe_get_coalesce\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_set_coalesce(struct net_device *netdev,
|
||||
struct ethtool_coalesce *ec)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
struct xgbe_hw_if *hw_if = &pdata->hw_if;
|
||||
unsigned int rx_frames, rx_riwt, rx_usecs;
|
||||
unsigned int tx_frames, tx_usecs;
|
||||
|
||||
DBGPR("-->xgbe_set_coalesce\n");
|
||||
|
||||
/* Check for not supported parameters */
|
||||
if ((ec->rx_coalesce_usecs_irq) ||
|
||||
(ec->rx_max_coalesced_frames_irq) ||
|
||||
(ec->tx_coalesce_usecs_irq) ||
|
||||
(ec->tx_max_coalesced_frames_irq) ||
|
||||
(ec->stats_block_coalesce_usecs) ||
|
||||
(ec->use_adaptive_rx_coalesce) ||
|
||||
(ec->use_adaptive_tx_coalesce) ||
|
||||
(ec->pkt_rate_low) ||
|
||||
(ec->rx_coalesce_usecs_low) ||
|
||||
(ec->rx_max_coalesced_frames_low) ||
|
||||
(ec->tx_coalesce_usecs_low) ||
|
||||
(ec->tx_max_coalesced_frames_low) ||
|
||||
(ec->pkt_rate_high) ||
|
||||
(ec->rx_coalesce_usecs_high) ||
|
||||
(ec->rx_max_coalesced_frames_high) ||
|
||||
(ec->tx_coalesce_usecs_high) ||
|
||||
(ec->tx_max_coalesced_frames_high) ||
|
||||
(ec->rate_sample_interval))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* Can only change rx-frames when interface is down (see
|
||||
* rx_descriptor_init in xgbe-dev.c)
|
||||
*/
|
||||
rx_frames = pdata->rx_frames;
|
||||
if (rx_frames != ec->rx_max_coalesced_frames && netif_running(netdev)) {
|
||||
netdev_alert(netdev,
|
||||
"interface must be down to change rx-frames\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rx_riwt = hw_if->usec_to_riwt(pdata, ec->rx_coalesce_usecs);
|
||||
rx_frames = ec->rx_max_coalesced_frames;
|
||||
|
||||
/* Use smallest possible value if conversion resulted in zero */
|
||||
if (ec->rx_coalesce_usecs && !rx_riwt)
|
||||
rx_riwt = 1;
|
||||
|
||||
/* Check the bounds of values for Rx */
|
||||
if (rx_riwt > XGMAC_MAX_DMA_RIWT) {
|
||||
rx_usecs = hw_if->riwt_to_usec(pdata, XGMAC_MAX_DMA_RIWT);
|
||||
netdev_alert(netdev, "rx-usec is limited to %d usecs\n",
|
||||
rx_usecs);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (rx_frames > pdata->channel->rx_ring->rdesc_count) {
|
||||
netdev_alert(netdev, "rx-frames is limited to %d frames\n",
|
||||
pdata->channel->rx_ring->rdesc_count);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tx_usecs = ec->tx_coalesce_usecs;
|
||||
tx_frames = ec->tx_max_coalesced_frames;
|
||||
|
||||
/* Check the bounds of values for Tx */
|
||||
if (tx_frames > pdata->channel->tx_ring->rdesc_count) {
|
||||
netdev_alert(netdev, "tx-frames is limited to %d frames\n",
|
||||
pdata->channel->tx_ring->rdesc_count);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pdata->rx_riwt = rx_riwt;
|
||||
pdata->rx_frames = rx_frames;
|
||||
hw_if->config_rx_coalesce(pdata);
|
||||
|
||||
pdata->tx_usecs = tx_usecs;
|
||||
pdata->tx_frames = tx_frames;
|
||||
hw_if->config_tx_coalesce(pdata);
|
||||
|
||||
DBGPR("<--xgbe_set_coalesce\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_get_ts_info(struct net_device *netdev,
|
||||
struct ethtool_ts_info *ts_info)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
|
||||
ts_info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
|
||||
SOF_TIMESTAMPING_RX_SOFTWARE |
|
||||
SOF_TIMESTAMPING_SOFTWARE |
|
||||
SOF_TIMESTAMPING_TX_HARDWARE |
|
||||
SOF_TIMESTAMPING_RX_HARDWARE |
|
||||
SOF_TIMESTAMPING_RAW_HARDWARE;
|
||||
|
||||
if (pdata->ptp_clock)
|
||||
ts_info->phc_index = ptp_clock_index(pdata->ptp_clock);
|
||||
else
|
||||
ts_info->phc_index = -1;
|
||||
|
||||
ts_info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
|
||||
ts_info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
|
||||
(1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) |
|
||||
(1 << HWTSTAMP_FILTER_ALL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct ethtool_ops xgbe_ethtool_ops = {
|
||||
.get_settings = xgbe_get_settings,
|
||||
.set_settings = xgbe_set_settings,
|
||||
.get_drvinfo = xgbe_get_drvinfo,
|
||||
.get_link = ethtool_op_get_link,
|
||||
.get_coalesce = xgbe_get_coalesce,
|
||||
.set_coalesce = xgbe_set_coalesce,
|
||||
.get_pauseparam = xgbe_get_pauseparam,
|
||||
.set_pauseparam = xgbe_set_pauseparam,
|
||||
.get_strings = xgbe_get_strings,
|
||||
.get_ethtool_stats = xgbe_get_ethtool_stats,
|
||||
.get_sset_count = xgbe_get_sset_count,
|
||||
.get_ts_info = xgbe_get_ts_info,
|
||||
};
|
||||
|
||||
struct ethtool_ops *xgbe_get_ethtool_ops(void)
|
||||
{
|
||||
return (struct ethtool_ops *)&xgbe_ethtool_ops;
|
||||
}
|
552
drivers/net/ethernet/amd/xgbe/xgbe-main.c
Normal file
552
drivers/net/ethernet/amd/xgbe/xgbe-main.c
Normal file
|
@ -0,0 +1,552 @@
|
|||
/*
|
||||
* AMD 10Gb Ethernet driver
|
||||
*
|
||||
* This file is available to you under your choice of the following two
|
||||
* licenses:
|
||||
*
|
||||
* License 1: GPLv2
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* This file is free software; you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* License 2: Modified BSD
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_net.h>
|
||||
#include <linux/clk.h>
|
||||
|
||||
#include "xgbe.h"
|
||||
#include "xgbe-common.h"
|
||||
|
||||
MODULE_AUTHOR("Tom Lendacky <thomas.lendacky@amd.com>");
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
MODULE_VERSION(XGBE_DRV_VERSION);
|
||||
MODULE_DESCRIPTION(XGBE_DRV_DESC);
|
||||
|
||||
static struct xgbe_channel *xgbe_alloc_rings(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct xgbe_channel *channel_mem, *channel;
|
||||
struct xgbe_ring *tx_ring, *rx_ring;
|
||||
unsigned int count, i;
|
||||
|
||||
DBGPR("-->xgbe_alloc_rings\n");
|
||||
|
||||
count = max_t(unsigned int, pdata->tx_ring_count, pdata->rx_ring_count);
|
||||
|
||||
channel_mem = devm_kcalloc(pdata->dev, count,
|
||||
sizeof(struct xgbe_channel), GFP_KERNEL);
|
||||
if (!channel_mem)
|
||||
return NULL;
|
||||
|
||||
tx_ring = devm_kcalloc(pdata->dev, pdata->tx_ring_count,
|
||||
sizeof(struct xgbe_ring), GFP_KERNEL);
|
||||
if (!tx_ring)
|
||||
return NULL;
|
||||
|
||||
rx_ring = devm_kcalloc(pdata->dev, pdata->rx_ring_count,
|
||||
sizeof(struct xgbe_ring), GFP_KERNEL);
|
||||
if (!rx_ring)
|
||||
return NULL;
|
||||
|
||||
for (i = 0, channel = channel_mem; i < count; i++, channel++) {
|
||||
snprintf(channel->name, sizeof(channel->name), "channel-%d", i);
|
||||
channel->pdata = pdata;
|
||||
channel->queue_index = i;
|
||||
channel->dma_regs = pdata->xgmac_regs + DMA_CH_BASE +
|
||||
(DMA_CH_INC * i);
|
||||
|
||||
if (i < pdata->tx_ring_count) {
|
||||
spin_lock_init(&tx_ring->lock);
|
||||
channel->tx_ring = tx_ring++;
|
||||
}
|
||||
|
||||
if (i < pdata->rx_ring_count) {
|
||||
spin_lock_init(&rx_ring->lock);
|
||||
channel->rx_ring = rx_ring++;
|
||||
}
|
||||
|
||||
DBGPR(" %s - queue_index=%u, dma_regs=%p, tx=%p, rx=%p\n",
|
||||
channel->name, channel->queue_index, channel->dma_regs,
|
||||
channel->tx_ring, channel->rx_ring);
|
||||
}
|
||||
|
||||
pdata->channel_count = count;
|
||||
|
||||
DBGPR("<--xgbe_alloc_rings\n");
|
||||
|
||||
return channel_mem;
|
||||
}
|
||||
|
||||
static void xgbe_default_config(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
DBGPR("-->xgbe_default_config\n");
|
||||
|
||||
pdata->pblx8 = DMA_PBL_X8_ENABLE;
|
||||
pdata->tx_sf_mode = MTL_TSF_ENABLE;
|
||||
pdata->tx_threshold = MTL_TX_THRESHOLD_64;
|
||||
pdata->tx_pbl = DMA_PBL_16;
|
||||
pdata->tx_osp_mode = DMA_OSP_ENABLE;
|
||||
pdata->rx_sf_mode = MTL_RSF_DISABLE;
|
||||
pdata->rx_threshold = MTL_RX_THRESHOLD_64;
|
||||
pdata->rx_pbl = DMA_PBL_16;
|
||||
pdata->pause_autoneg = 1;
|
||||
pdata->tx_pause = 1;
|
||||
pdata->rx_pause = 1;
|
||||
pdata->power_down = 0;
|
||||
pdata->default_autoneg = AUTONEG_ENABLE;
|
||||
pdata->default_speed = SPEED_10000;
|
||||
|
||||
DBGPR("<--xgbe_default_config\n");
|
||||
}
|
||||
|
||||
static void xgbe_init_all_fptrs(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
xgbe_init_function_ptrs_dev(&pdata->hw_if);
|
||||
xgbe_init_function_ptrs_desc(&pdata->desc_if);
|
||||
}
|
||||
|
||||
static int xgbe_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct xgbe_prv_data *pdata;
|
||||
struct xgbe_hw_if *hw_if;
|
||||
struct xgbe_desc_if *desc_if;
|
||||
struct net_device *netdev;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct resource *res;
|
||||
const u8 *mac_addr;
|
||||
int ret;
|
||||
|
||||
DBGPR("--> xgbe_probe\n");
|
||||
|
||||
netdev = alloc_etherdev_mq(sizeof(struct xgbe_prv_data),
|
||||
XGBE_MAX_DMA_CHANNELS);
|
||||
if (!netdev) {
|
||||
dev_err(dev, "alloc_etherdev failed\n");
|
||||
ret = -ENOMEM;
|
||||
goto err_alloc;
|
||||
}
|
||||
SET_NETDEV_DEV(netdev, dev);
|
||||
pdata = netdev_priv(netdev);
|
||||
pdata->netdev = netdev;
|
||||
pdata->pdev = pdev;
|
||||
pdata->dev = dev;
|
||||
platform_set_drvdata(pdev, netdev);
|
||||
|
||||
spin_lock_init(&pdata->lock);
|
||||
mutex_init(&pdata->xpcs_mutex);
|
||||
spin_lock_init(&pdata->tstamp_lock);
|
||||
|
||||
/* Set and validate the number of descriptors for a ring */
|
||||
BUILD_BUG_ON_NOT_POWER_OF_2(XGBE_TX_DESC_CNT);
|
||||
pdata->tx_desc_count = XGBE_TX_DESC_CNT;
|
||||
if (pdata->tx_desc_count & (pdata->tx_desc_count - 1)) {
|
||||
dev_err(dev, "tx descriptor count (%d) is not valid\n",
|
||||
pdata->tx_desc_count);
|
||||
ret = -EINVAL;
|
||||
goto err_io;
|
||||
}
|
||||
BUILD_BUG_ON_NOT_POWER_OF_2(XGBE_RX_DESC_CNT);
|
||||
pdata->rx_desc_count = XGBE_RX_DESC_CNT;
|
||||
if (pdata->rx_desc_count & (pdata->rx_desc_count - 1)) {
|
||||
dev_err(dev, "rx descriptor count (%d) is not valid\n",
|
||||
pdata->rx_desc_count);
|
||||
ret = -EINVAL;
|
||||
goto err_io;
|
||||
}
|
||||
|
||||
/* Obtain the system clock setting */
|
||||
pdata->sysclk = devm_clk_get(dev, XGBE_DMA_CLOCK);
|
||||
if (IS_ERR(pdata->sysclk)) {
|
||||
dev_err(dev, "dma devm_clk_get failed\n");
|
||||
ret = PTR_ERR(pdata->sysclk);
|
||||
goto err_io;
|
||||
}
|
||||
|
||||
/* Obtain the PTP clock setting */
|
||||
pdata->ptpclk = devm_clk_get(dev, XGBE_PTP_CLOCK);
|
||||
if (IS_ERR(pdata->ptpclk)) {
|
||||
dev_err(dev, "ptp devm_clk_get failed\n");
|
||||
ret = PTR_ERR(pdata->ptpclk);
|
||||
goto err_io;
|
||||
}
|
||||
|
||||
/* Obtain the mmio areas for the device */
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
pdata->xgmac_regs = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(pdata->xgmac_regs)) {
|
||||
dev_err(dev, "xgmac ioremap failed\n");
|
||||
ret = PTR_ERR(pdata->xgmac_regs);
|
||||
goto err_io;
|
||||
}
|
||||
DBGPR(" xgmac_regs = %p\n", pdata->xgmac_regs);
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
||||
pdata->xpcs_regs = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(pdata->xpcs_regs)) {
|
||||
dev_err(dev, "xpcs ioremap failed\n");
|
||||
ret = PTR_ERR(pdata->xpcs_regs);
|
||||
goto err_io;
|
||||
}
|
||||
DBGPR(" xpcs_regs = %p\n", pdata->xpcs_regs);
|
||||
|
||||
/* Set the DMA mask */
|
||||
if (!dev->dma_mask)
|
||||
dev->dma_mask = &dev->coherent_dma_mask;
|
||||
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
|
||||
if (ret) {
|
||||
dev_err(dev, "dma_set_mask_and_coherent failed\n");
|
||||
goto err_io;
|
||||
}
|
||||
|
||||
if (of_property_read_bool(dev->of_node, "dma-coherent")) {
|
||||
pdata->axdomain = XGBE_DMA_OS_AXDOMAIN;
|
||||
pdata->arcache = XGBE_DMA_OS_ARCACHE;
|
||||
pdata->awcache = XGBE_DMA_OS_AWCACHE;
|
||||
} else {
|
||||
pdata->axdomain = XGBE_DMA_SYS_AXDOMAIN;
|
||||
pdata->arcache = XGBE_DMA_SYS_ARCACHE;
|
||||
pdata->awcache = XGBE_DMA_SYS_AWCACHE;
|
||||
}
|
||||
|
||||
ret = platform_get_irq(pdev, 0);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "platform_get_irq failed\n");
|
||||
goto err_io;
|
||||
}
|
||||
netdev->irq = ret;
|
||||
netdev->base_addr = (unsigned long)pdata->xgmac_regs;
|
||||
|
||||
/* Set all the function pointers */
|
||||
xgbe_init_all_fptrs(pdata);
|
||||
hw_if = &pdata->hw_if;
|
||||
desc_if = &pdata->desc_if;
|
||||
|
||||
/* Issue software reset to device */
|
||||
hw_if->exit(pdata);
|
||||
|
||||
/* Populate the hardware features */
|
||||
xgbe_get_all_hw_features(pdata);
|
||||
|
||||
/* Retrieve the MAC address */
|
||||
mac_addr = of_get_mac_address(dev->of_node);
|
||||
if (!mac_addr) {
|
||||
dev_err(dev, "invalid mac address for this device\n");
|
||||
ret = -EINVAL;
|
||||
goto err_io;
|
||||
}
|
||||
memcpy(netdev->dev_addr, mac_addr, netdev->addr_len);
|
||||
|
||||
/* Retrieve the PHY mode - it must be "xgmii" */
|
||||
pdata->phy_mode = of_get_phy_mode(dev->of_node);
|
||||
if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII) {
|
||||
dev_err(dev, "invalid phy-mode specified for this device\n");
|
||||
ret = -EINVAL;
|
||||
goto err_io;
|
||||
}
|
||||
|
||||
/* Set default configuration data */
|
||||
xgbe_default_config(pdata);
|
||||
|
||||
/* Calculate the number of Tx and Rx rings to be created
|
||||
* -Tx (DMA) Channels map 1-to-1 to Tx Queues so set
|
||||
* the number of Tx queues to the number of Tx channels
|
||||
* enabled
|
||||
* -Rx (DMA) Channels do not map 1-to-1 so use the actual
|
||||
* number of Rx queues
|
||||
*/
|
||||
pdata->tx_ring_count = min_t(unsigned int, num_online_cpus(),
|
||||
pdata->hw_feat.tx_ch_cnt);
|
||||
pdata->tx_q_count = pdata->tx_ring_count;
|
||||
ret = netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count);
|
||||
if (ret) {
|
||||
dev_err(dev, "error setting real tx queue count\n");
|
||||
goto err_io;
|
||||
}
|
||||
|
||||
pdata->rx_ring_count = min_t(unsigned int,
|
||||
netif_get_num_default_rss_queues(),
|
||||
pdata->hw_feat.rx_ch_cnt);
|
||||
pdata->rx_q_count = pdata->hw_feat.rx_q_cnt;
|
||||
ret = netif_set_real_num_rx_queues(netdev, pdata->rx_ring_count);
|
||||
if (ret) {
|
||||
dev_err(dev, "error setting real rx queue count\n");
|
||||
goto err_io;
|
||||
}
|
||||
|
||||
/* Allocate the rings for the DMA channels */
|
||||
pdata->channel = xgbe_alloc_rings(pdata);
|
||||
if (!pdata->channel) {
|
||||
dev_err(dev, "ring allocation failed\n");
|
||||
ret = -ENOMEM;
|
||||
goto err_io;
|
||||
}
|
||||
|
||||
/* Prepare to regsiter with MDIO */
|
||||
pdata->mii_bus_id = kasprintf(GFP_KERNEL, "%s", pdev->name);
|
||||
if (!pdata->mii_bus_id) {
|
||||
dev_err(dev, "failed to allocate mii bus id\n");
|
||||
ret = -ENOMEM;
|
||||
goto err_io;
|
||||
}
|
||||
ret = xgbe_mdio_register(pdata);
|
||||
if (ret)
|
||||
goto err_bus_id;
|
||||
|
||||
/* Set device operations */
|
||||
netdev->netdev_ops = xgbe_get_netdev_ops();
|
||||
netdev->ethtool_ops = xgbe_get_ethtool_ops();
|
||||
#ifdef CONFIG_AMD_XGBE_DCB
|
||||
netdev->dcbnl_ops = xgbe_get_dcbnl_ops();
|
||||
#endif
|
||||
|
||||
/* Set device features */
|
||||
netdev->hw_features = NETIF_F_SG |
|
||||
NETIF_F_IP_CSUM |
|
||||
NETIF_F_IPV6_CSUM |
|
||||
NETIF_F_RXCSUM |
|
||||
NETIF_F_TSO |
|
||||
NETIF_F_TSO6 |
|
||||
NETIF_F_GRO |
|
||||
NETIF_F_HW_VLAN_CTAG_RX |
|
||||
NETIF_F_HW_VLAN_CTAG_TX |
|
||||
NETIF_F_HW_VLAN_CTAG_FILTER;
|
||||
|
||||
netdev->vlan_features |= NETIF_F_SG |
|
||||
NETIF_F_IP_CSUM |
|
||||
NETIF_F_IPV6_CSUM |
|
||||
NETIF_F_TSO |
|
||||
NETIF_F_TSO6;
|
||||
|
||||
netdev->features |= netdev->hw_features;
|
||||
pdata->netdev_features = netdev->features;
|
||||
|
||||
netdev->priv_flags |= IFF_UNICAST_FLT;
|
||||
|
||||
xgbe_init_rx_coalesce(pdata);
|
||||
xgbe_init_tx_coalesce(pdata);
|
||||
|
||||
netif_carrier_off(netdev);
|
||||
ret = register_netdev(netdev);
|
||||
if (ret) {
|
||||
dev_err(dev, "net device registration failed\n");
|
||||
goto err_reg_netdev;
|
||||
}
|
||||
|
||||
xgbe_ptp_register(pdata);
|
||||
|
||||
xgbe_debugfs_init(pdata);
|
||||
|
||||
netdev_notice(netdev, "net device enabled\n");
|
||||
|
||||
DBGPR("<-- xgbe_probe\n");
|
||||
|
||||
return 0;
|
||||
|
||||
err_reg_netdev:
|
||||
xgbe_mdio_unregister(pdata);
|
||||
|
||||
err_bus_id:
|
||||
kfree(pdata->mii_bus_id);
|
||||
|
||||
err_io:
|
||||
free_netdev(netdev);
|
||||
|
||||
err_alloc:
|
||||
dev_notice(dev, "net device not enabled\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int xgbe_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct net_device *netdev = platform_get_drvdata(pdev);
|
||||
struct xgbe_prv_data *pdata = netdev_priv(netdev);
|
||||
|
||||
DBGPR("-->xgbe_remove\n");
|
||||
|
||||
xgbe_debugfs_exit(pdata);
|
||||
|
||||
xgbe_ptp_unregister(pdata);
|
||||
|
||||
unregister_netdev(netdev);
|
||||
|
||||
xgbe_mdio_unregister(pdata);
|
||||
|
||||
kfree(pdata->mii_bus_id);
|
||||
|
||||
free_netdev(netdev);
|
||||
|
||||
DBGPR("<--xgbe_remove\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int xgbe_suspend(struct device *dev)
|
||||
{
|
||||
struct net_device *netdev = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
DBGPR("-->xgbe_suspend\n");
|
||||
|
||||
if (!netif_running(netdev)) {
|
||||
DBGPR("<--xgbe_dev_suspend\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = xgbe_powerdown(netdev, XGMAC_DRIVER_CONTEXT);
|
||||
|
||||
DBGPR("<--xgbe_suspend\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int xgbe_resume(struct device *dev)
|
||||
{
|
||||
struct net_device *netdev = dev_get_drvdata(dev);
|
||||
int ret;
|
||||
|
||||
DBGPR("-->xgbe_resume\n");
|
||||
|
||||
if (!netif_running(netdev)) {
|
||||
DBGPR("<--xgbe_dev_resume\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = xgbe_powerup(netdev, XGMAC_DRIVER_CONTEXT);
|
||||
|
||||
DBGPR("<--xgbe_resume\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
static const struct of_device_id xgbe_of_match[] = {
|
||||
{ .compatible = "amd,xgbe-seattle-v1a", },
|
||||
{},
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, xgbe_of_match);
|
||||
static SIMPLE_DEV_PM_OPS(xgbe_pm_ops, xgbe_suspend, xgbe_resume);
|
||||
|
||||
static struct platform_driver xgbe_driver = {
|
||||
.driver = {
|
||||
.name = "amd-xgbe",
|
||||
.of_match_table = xgbe_of_match,
|
||||
.pm = &xgbe_pm_ops,
|
||||
},
|
||||
.probe = xgbe_probe,
|
||||
.remove = xgbe_remove,
|
||||
};
|
||||
|
||||
module_platform_driver(xgbe_driver);
|
325
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
Normal file
325
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c
Normal file
|
@ -0,0 +1,325 @@
|
|||
/*
|
||||
* AMD 10Gb Ethernet driver
|
||||
*
|
||||
* This file is available to you under your choice of the following two
|
||||
* licenses:
|
||||
*
|
||||
* License 1: GPLv2
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* This file is free software; you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* License 2: Modified BSD
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/mdio.h>
|
||||
#include <linux/phy.h>
|
||||
#include <linux/of.h>
|
||||
|
||||
#include "xgbe.h"
|
||||
#include "xgbe-common.h"
|
||||
|
||||
static int xgbe_mdio_read(struct mii_bus *mii, int prtad, int mmd_reg)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = mii->priv;
|
||||
struct xgbe_hw_if *hw_if = &pdata->hw_if;
|
||||
int mmd_data;
|
||||
|
||||
DBGPR_MDIO("-->xgbe_mdio_read: prtad=%#x mmd_reg=%#x\n",
|
||||
prtad, mmd_reg);
|
||||
|
||||
mmd_data = hw_if->read_mmd_regs(pdata, prtad, mmd_reg);
|
||||
|
||||
DBGPR_MDIO("<--xgbe_mdio_read: mmd_data=%#x\n", mmd_data);
|
||||
|
||||
return mmd_data;
|
||||
}
|
||||
|
||||
static int xgbe_mdio_write(struct mii_bus *mii, int prtad, int mmd_reg,
|
||||
u16 mmd_val)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = mii->priv;
|
||||
struct xgbe_hw_if *hw_if = &pdata->hw_if;
|
||||
int mmd_data = mmd_val;
|
||||
|
||||
DBGPR_MDIO("-->xgbe_mdio_write: prtad=%#x mmd_reg=%#x mmd_data=%#x\n",
|
||||
prtad, mmd_reg, mmd_data);
|
||||
|
||||
hw_if->write_mmd_regs(pdata, prtad, mmd_reg, mmd_data);
|
||||
|
||||
DBGPR_MDIO("<--xgbe_mdio_write\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xgbe_dump_phy_registers(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct device *dev = pdata->dev;
|
||||
struct phy_device *phydev = pdata->mii->phy_map[XGBE_PRTAD];
|
||||
int i;
|
||||
|
||||
dev_alert(dev, "\n************* PHY Reg dump **********************\n");
|
||||
|
||||
dev_alert(dev, "PCS Control Reg (%#04x) = %#04x\n", MDIO_CTRL1,
|
||||
XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL1));
|
||||
dev_alert(dev, "PCS Status Reg (%#04x) = %#04x\n", MDIO_STAT1,
|
||||
XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1));
|
||||
dev_alert(dev, "Phy Id (PHYS ID 1 %#04x)= %#04x\n", MDIO_DEVID1,
|
||||
XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_DEVID1));
|
||||
dev_alert(dev, "Phy Id (PHYS ID 2 %#04x)= %#04x\n", MDIO_DEVID2,
|
||||
XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_DEVID2));
|
||||
dev_alert(dev, "Devices in Package (%#04x)= %#04x\n", MDIO_DEVS1,
|
||||
XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_DEVS1));
|
||||
dev_alert(dev, "Devices in Package (%#04x)= %#04x\n", MDIO_DEVS2,
|
||||
XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_DEVS2));
|
||||
|
||||
dev_alert(dev, "Auto-Neg Control Reg (%#04x) = %#04x\n", MDIO_CTRL1,
|
||||
XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_CTRL1));
|
||||
dev_alert(dev, "Auto-Neg Status Reg (%#04x) = %#04x\n", MDIO_STAT1,
|
||||
XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_STAT1));
|
||||
dev_alert(dev, "Auto-Neg Ad Reg 1 (%#04x) = %#04x\n",
|
||||
MDIO_AN_ADVERTISE,
|
||||
XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE));
|
||||
dev_alert(dev, "Auto-Neg Ad Reg 2 (%#04x) = %#04x\n",
|
||||
MDIO_AN_ADVERTISE + 1,
|
||||
XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1));
|
||||
dev_alert(dev, "Auto-Neg Ad Reg 3 (%#04x) = %#04x\n",
|
||||
MDIO_AN_ADVERTISE + 2,
|
||||
XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2));
|
||||
dev_alert(dev, "Auto-Neg Completion Reg (%#04x) = %#04x\n",
|
||||
MDIO_AN_COMP_STAT,
|
||||
XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_COMP_STAT));
|
||||
|
||||
dev_alert(dev, "MMD Device Mask = %#x\n",
|
||||
phydev->c45_ids.devices_in_package);
|
||||
for (i = 0; i < ARRAY_SIZE(phydev->c45_ids.device_ids); i++)
|
||||
dev_alert(dev, " MMD %d: ID = %#08x\n", i,
|
||||
phydev->c45_ids.device_ids[i]);
|
||||
|
||||
dev_alert(dev, "\n*************************************************\n");
|
||||
}
|
||||
|
||||
int xgbe_mdio_register(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct device_node *phy_node;
|
||||
struct mii_bus *mii;
|
||||
struct phy_device *phydev;
|
||||
int ret = 0;
|
||||
|
||||
DBGPR("-->xgbe_mdio_register\n");
|
||||
|
||||
/* Retrieve the phy-handle */
|
||||
phy_node = of_parse_phandle(pdata->dev->of_node, "phy-handle", 0);
|
||||
if (!phy_node) {
|
||||
dev_err(pdata->dev, "unable to parse phy-handle\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mii = mdiobus_alloc();
|
||||
if (mii == NULL) {
|
||||
dev_err(pdata->dev, "mdiobus_alloc failed\n");
|
||||
ret = -ENOMEM;
|
||||
goto err_node_get;
|
||||
}
|
||||
|
||||
/* Register on the MDIO bus (don't probe any PHYs) */
|
||||
mii->name = XGBE_PHY_NAME;
|
||||
mii->read = xgbe_mdio_read;
|
||||
mii->write = xgbe_mdio_write;
|
||||
snprintf(mii->id, sizeof(mii->id), "%s", pdata->mii_bus_id);
|
||||
mii->priv = pdata;
|
||||
mii->phy_mask = ~0;
|
||||
mii->parent = pdata->dev;
|
||||
ret = mdiobus_register(mii);
|
||||
if (ret) {
|
||||
dev_err(pdata->dev, "mdiobus_register failed\n");
|
||||
goto err_mdiobus_alloc;
|
||||
}
|
||||
DBGPR(" mdiobus_register succeeded for %s\n", pdata->mii_bus_id);
|
||||
|
||||
/* Probe the PCS using Clause 45 */
|
||||
phydev = get_phy_device(mii, XGBE_PRTAD, true);
|
||||
if (IS_ERR(phydev) || !phydev ||
|
||||
!phydev->c45_ids.device_ids[MDIO_MMD_PCS]) {
|
||||
dev_err(pdata->dev, "get_phy_device failed\n");
|
||||
ret = phydev ? PTR_ERR(phydev) : -ENOLINK;
|
||||
goto err_mdiobus_register;
|
||||
}
|
||||
request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT,
|
||||
MDIO_ID_ARGS(phydev->c45_ids.device_ids[MDIO_MMD_PCS]));
|
||||
|
||||
of_node_get(phy_node);
|
||||
phydev->dev.of_node = phy_node;
|
||||
ret = phy_device_register(phydev);
|
||||
if (ret) {
|
||||
dev_err(pdata->dev, "phy_device_register failed\n");
|
||||
of_node_put(phy_node);
|
||||
goto err_phy_device;
|
||||
}
|
||||
|
||||
/* Add a reference to the PHY driver so it can't be unloaded */
|
||||
pdata->phy_module = phydev->dev.driver ?
|
||||
phydev->dev.driver->owner : NULL;
|
||||
if (!try_module_get(pdata->phy_module)) {
|
||||
dev_err(pdata->dev, "try_module_get failed\n");
|
||||
ret = -EIO;
|
||||
goto err_phy_device;
|
||||
}
|
||||
|
||||
pdata->mii = mii;
|
||||
pdata->mdio_mmd = MDIO_MMD_PCS;
|
||||
|
||||
phydev->autoneg = pdata->default_autoneg;
|
||||
if (phydev->autoneg == AUTONEG_DISABLE) {
|
||||
phydev->speed = pdata->default_speed;
|
||||
phydev->duplex = DUPLEX_FULL;
|
||||
|
||||
phydev->advertising &= ~ADVERTISED_Autoneg;
|
||||
}
|
||||
|
||||
pdata->phydev = phydev;
|
||||
|
||||
of_node_put(phy_node);
|
||||
|
||||
DBGPHY_REGS(pdata);
|
||||
|
||||
DBGPR("<--xgbe_mdio_register\n");
|
||||
|
||||
return 0;
|
||||
|
||||
err_phy_device:
|
||||
phy_device_free(phydev);
|
||||
|
||||
err_mdiobus_register:
|
||||
mdiobus_unregister(mii);
|
||||
|
||||
err_mdiobus_alloc:
|
||||
mdiobus_free(mii);
|
||||
|
||||
err_node_get:
|
||||
of_node_put(phy_node);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void xgbe_mdio_unregister(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
DBGPR("-->xgbe_mdio_unregister\n");
|
||||
|
||||
pdata->phydev = NULL;
|
||||
|
||||
module_put(pdata->phy_module);
|
||||
pdata->phy_module = NULL;
|
||||
|
||||
mdiobus_unregister(pdata->mii);
|
||||
pdata->mii->priv = NULL;
|
||||
|
||||
mdiobus_free(pdata->mii);
|
||||
pdata->mii = NULL;
|
||||
|
||||
DBGPR("<--xgbe_mdio_unregister\n");
|
||||
}
|
284
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
Normal file
284
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c
Normal file
|
@ -0,0 +1,284 @@
|
|||
/*
|
||||
* AMD 10Gb Ethernet driver
|
||||
*
|
||||
* This file is available to you under your choice of the following two
|
||||
* licenses:
|
||||
*
|
||||
* License 1: GPLv2
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* This file is free software; you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* License 2: Modified BSD
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/clocksource.h>
|
||||
#include <linux/ptp_clock_kernel.h>
|
||||
#include <linux/net_tstamp.h>
|
||||
|
||||
#include "xgbe.h"
|
||||
#include "xgbe-common.h"
|
||||
|
||||
static cycle_t xgbe_cc_read(const struct cyclecounter *cc)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = container_of(cc,
|
||||
struct xgbe_prv_data,
|
||||
tstamp_cc);
|
||||
u64 nsec;
|
||||
|
||||
nsec = pdata->hw_if.get_tstamp_time(pdata);
|
||||
|
||||
return nsec;
|
||||
}
|
||||
|
||||
static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = container_of(info,
|
||||
struct xgbe_prv_data,
|
||||
ptp_clock_info);
|
||||
unsigned long flags;
|
||||
u64 adjust;
|
||||
u32 addend, diff;
|
||||
unsigned int neg_adjust = 0;
|
||||
|
||||
if (delta < 0) {
|
||||
neg_adjust = 1;
|
||||
delta = -delta;
|
||||
}
|
||||
|
||||
adjust = pdata->tstamp_addend;
|
||||
adjust *= delta;
|
||||
diff = div_u64(adjust, 1000000000UL);
|
||||
|
||||
addend = (neg_adjust) ? pdata->tstamp_addend - diff :
|
||||
pdata->tstamp_addend + diff;
|
||||
|
||||
spin_lock_irqsave(&pdata->tstamp_lock, flags);
|
||||
|
||||
pdata->hw_if.update_tstamp_addend(pdata, addend);
|
||||
|
||||
spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_adjtime(struct ptp_clock_info *info, s64 delta)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = container_of(info,
|
||||
struct xgbe_prv_data,
|
||||
ptp_clock_info);
|
||||
unsigned long flags;
|
||||
u64 nsec;
|
||||
|
||||
spin_lock_irqsave(&pdata->tstamp_lock, flags);
|
||||
|
||||
nsec = timecounter_read(&pdata->tstamp_tc);
|
||||
|
||||
nsec += delta;
|
||||
timecounter_init(&pdata->tstamp_tc, &pdata->tstamp_cc, nsec);
|
||||
|
||||
spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_gettime(struct ptp_clock_info *info, struct timespec *ts)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = container_of(info,
|
||||
struct xgbe_prv_data,
|
||||
ptp_clock_info);
|
||||
unsigned long flags;
|
||||
u64 nsec;
|
||||
|
||||
spin_lock_irqsave(&pdata->tstamp_lock, flags);
|
||||
|
||||
nsec = timecounter_read(&pdata->tstamp_tc);
|
||||
|
||||
spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
|
||||
|
||||
*ts = ns_to_timespec(nsec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_settime(struct ptp_clock_info *info, const struct timespec *ts)
|
||||
{
|
||||
struct xgbe_prv_data *pdata = container_of(info,
|
||||
struct xgbe_prv_data,
|
||||
ptp_clock_info);
|
||||
unsigned long flags;
|
||||
u64 nsec;
|
||||
|
||||
nsec = timespec_to_ns(ts);
|
||||
|
||||
spin_lock_irqsave(&pdata->tstamp_lock, flags);
|
||||
|
||||
timecounter_init(&pdata->tstamp_tc, &pdata->tstamp_cc, nsec);
|
||||
|
||||
spin_unlock_irqrestore(&pdata->tstamp_lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xgbe_enable(struct ptp_clock_info *info,
|
||||
struct ptp_clock_request *request, int on)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
void xgbe_ptp_register(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
struct ptp_clock_info *info = &pdata->ptp_clock_info;
|
||||
struct ptp_clock *clock;
|
||||
struct cyclecounter *cc = &pdata->tstamp_cc;
|
||||
u64 dividend;
|
||||
|
||||
snprintf(info->name, sizeof(info->name), "%s",
|
||||
netdev_name(pdata->netdev));
|
||||
info->owner = THIS_MODULE;
|
||||
info->max_adj = clk_get_rate(pdata->ptpclk);
|
||||
info->adjfreq = xgbe_adjfreq;
|
||||
info->adjtime = xgbe_adjtime;
|
||||
info->gettime = xgbe_gettime;
|
||||
info->settime = xgbe_settime;
|
||||
info->enable = xgbe_enable;
|
||||
|
||||
clock = ptp_clock_register(info, pdata->dev);
|
||||
if (IS_ERR(clock)) {
|
||||
dev_err(pdata->dev, "ptp_clock_register failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pdata->ptp_clock = clock;
|
||||
|
||||
/* Calculate the addend:
|
||||
* addend = 2^32 / (PTP ref clock / 50Mhz)
|
||||
* = (2^32 * 50Mhz) / PTP ref clock
|
||||
*/
|
||||
dividend = 50000000;
|
||||
dividend <<= 32;
|
||||
pdata->tstamp_addend = div_u64(dividend, clk_get_rate(pdata->ptpclk));
|
||||
|
||||
/* Setup the timecounter */
|
||||
cc->read = xgbe_cc_read;
|
||||
cc->mask = CLOCKSOURCE_MASK(64);
|
||||
cc->mult = 1;
|
||||
cc->shift = 0;
|
||||
|
||||
timecounter_init(&pdata->tstamp_tc, &pdata->tstamp_cc,
|
||||
ktime_to_ns(ktime_get_real()));
|
||||
|
||||
/* Disable all timestamping to start */
|
||||
XGMAC_IOWRITE(pdata, MAC_TCR, 0);
|
||||
pdata->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
|
||||
pdata->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE;
|
||||
}
|
||||
|
||||
void xgbe_ptp_unregister(struct xgbe_prv_data *pdata)
|
||||
{
|
||||
if (pdata->ptp_clock)
|
||||
ptp_clock_unregister(pdata->ptp_clock);
|
||||
}
|
767
drivers/net/ethernet/amd/xgbe/xgbe.h
Normal file
767
drivers/net/ethernet/amd/xgbe/xgbe.h
Normal file
|
@ -0,0 +1,767 @@
|
|||
/*
|
||||
* AMD 10Gb Ethernet driver
|
||||
*
|
||||
* This file is available to you under your choice of the following two
|
||||
* licenses:
|
||||
*
|
||||
* License 1: GPLv2
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
*
|
||||
* This file is free software; you may copy, redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* License 2: Modified BSD
|
||||
*
|
||||
* Copyright (c) 2014 Advanced Micro Devices, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices, Inc. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
* The Synopsys DWC ETHER XGMAC Software Driver and documentation
|
||||
* (hereinafter "Software") is an unsupported proprietary work of Synopsys,
|
||||
* Inc. unless otherwise expressly agreed to in writing between Synopsys
|
||||
* and you.
|
||||
*
|
||||
* The Software IS NOT an item of Licensed Software or Licensed Product
|
||||
* under any End User Software License Agreement or Agreement for Licensed
|
||||
* Product with Synopsys or any supplement thereto. Permission is hereby
|
||||
* granted, free of charge, to any person obtaining a copy of this software
|
||||
* annotated with this license and the Software, to deal in the Software
|
||||
* without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
* of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
|
||||
* BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __XGBE_H__
|
||||
#define __XGBE_H__
|
||||
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/phy.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/ptp_clock_kernel.h>
|
||||
#include <linux/clocksource.h>
|
||||
#include <linux/net_tstamp.h>
|
||||
#include <net/dcbnl.h>
|
||||
|
||||
#define XGBE_DRV_NAME "amd-xgbe"
|
||||
#define XGBE_DRV_VERSION "1.0.0-a"
|
||||
#define XGBE_DRV_DESC "AMD 10 Gigabit Ethernet Driver"
|
||||
|
||||
/* Descriptor related defines */
|
||||
#define XGBE_TX_DESC_CNT 512
|
||||
#define XGBE_TX_DESC_MIN_FREE (XGBE_TX_DESC_CNT >> 3)
|
||||
#define XGBE_TX_DESC_MAX_PROC (XGBE_TX_DESC_CNT >> 1)
|
||||
#define XGBE_RX_DESC_CNT 512
|
||||
|
||||
#define XGBE_TX_MAX_BUF_SIZE (0x3fff & ~(64 - 1))
|
||||
|
||||
#define XGBE_RX_MIN_BUF_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
|
||||
#define XGBE_RX_BUF_ALIGN 64
|
||||
|
||||
#define XGBE_MAX_DMA_CHANNELS 16
|
||||
#define XGBE_MAX_QUEUES 16
|
||||
|
||||
/* DMA cache settings - Outer sharable, write-back, write-allocate */
|
||||
#define XGBE_DMA_OS_AXDOMAIN 0x2
|
||||
#define XGBE_DMA_OS_ARCACHE 0xb
|
||||
#define XGBE_DMA_OS_AWCACHE 0xf
|
||||
|
||||
/* DMA cache settings - System, no caches used */
|
||||
#define XGBE_DMA_SYS_AXDOMAIN 0x3
|
||||
#define XGBE_DMA_SYS_ARCACHE 0x0
|
||||
#define XGBE_DMA_SYS_AWCACHE 0x0
|
||||
|
||||
#define XGBE_DMA_INTERRUPT_MASK 0x31c7
|
||||
|
||||
#define XGMAC_MIN_PACKET 60
|
||||
#define XGMAC_STD_PACKET_MTU 1500
|
||||
#define XGMAC_MAX_STD_PACKET 1518
|
||||
#define XGMAC_JUMBO_PACKET_MTU 9000
|
||||
#define XGMAC_MAX_JUMBO_PACKET 9018
|
||||
|
||||
/* MDIO bus phy name */
|
||||
#define XGBE_PHY_NAME "amd_xgbe_phy"
|
||||
#define XGBE_PRTAD 0
|
||||
|
||||
/* Device-tree clock names */
|
||||
#define XGBE_DMA_CLOCK "dma_clk"
|
||||
#define XGBE_PTP_CLOCK "ptp_clk"
|
||||
|
||||
/* Timestamp support - values based on 50MHz PTP clock
|
||||
* 50MHz => 20 nsec
|
||||
*/
|
||||
#define XGBE_TSTAMP_SSINC 20
|
||||
#define XGBE_TSTAMP_SNSINC 0
|
||||
|
||||
/* Driver PMT macros */
|
||||
#define XGMAC_DRIVER_CONTEXT 1
|
||||
#define XGMAC_IOCTL_CONTEXT 2
|
||||
|
||||
#define XGBE_FIFO_MAX 81920
|
||||
#define XGBE_FIFO_SIZE_B(x) (x)
|
||||
#define XGBE_FIFO_SIZE_KB(x) (x * 1024)
|
||||
|
||||
#define XGBE_TC_MIN_QUANTUM 10
|
||||
|
||||
/* Helper macro for descriptor handling
|
||||
* Always use XGBE_GET_DESC_DATA to access the descriptor data
|
||||
* since the index is free-running and needs to be and-ed
|
||||
* with the descriptor count value of the ring to index to
|
||||
* the proper descriptor data.
|
||||
*/
|
||||
#define XGBE_GET_DESC_DATA(_ring, _idx) \
|
||||
((_ring)->rdata + \
|
||||
((_idx) & ((_ring)->rdesc_count - 1)))
|
||||
|
||||
/* Default coalescing parameters */
|
||||
#define XGMAC_INIT_DMA_TX_USECS 50
|
||||
#define XGMAC_INIT_DMA_TX_FRAMES 25
|
||||
|
||||
#define XGMAC_MAX_DMA_RIWT 0xff
|
||||
#define XGMAC_INIT_DMA_RX_USECS 30
|
||||
#define XGMAC_INIT_DMA_RX_FRAMES 25
|
||||
|
||||
/* Flow control queue count */
|
||||
#define XGMAC_MAX_FLOW_CONTROL_QUEUES 8
|
||||
|
||||
/* Maximum MAC address hash table size (256 bits = 8 bytes) */
|
||||
#define XGBE_MAC_HASH_TABLE_SIZE 8
|
||||
|
||||
struct xgbe_prv_data;
|
||||
|
||||
struct xgbe_packet_data {
|
||||
unsigned int attributes;
|
||||
|
||||
unsigned int errors;
|
||||
|
||||
unsigned int rdesc_count;
|
||||
unsigned int length;
|
||||
|
||||
unsigned int header_len;
|
||||
unsigned int tcp_header_len;
|
||||
unsigned int tcp_payload_len;
|
||||
unsigned short mss;
|
||||
|
||||
unsigned short vlan_ctag;
|
||||
|
||||
u64 rx_tstamp;
|
||||
};
|
||||
|
||||
/* Common Rx and Tx descriptor mapping */
|
||||
struct xgbe_ring_desc {
|
||||
unsigned int desc0;
|
||||
unsigned int desc1;
|
||||
unsigned int desc2;
|
||||
unsigned int desc3;
|
||||
};
|
||||
|
||||
/* Structure used to hold information related to the descriptor
|
||||
* and the packet associated with the descriptor (always use
|
||||
* use the XGBE_GET_DESC_DATA macro to access this data from the ring)
|
||||
*/
|
||||
struct xgbe_ring_data {
|
||||
struct xgbe_ring_desc *rdesc; /* Virtual address of descriptor */
|
||||
dma_addr_t rdesc_dma; /* DMA address of descriptor */
|
||||
|
||||
struct sk_buff *skb; /* Virtual address of SKB */
|
||||
dma_addr_t skb_dma; /* DMA address of SKB data */
|
||||
unsigned int skb_dma_len; /* Length of SKB DMA area */
|
||||
unsigned int tso_header; /* TSO header indicator */
|
||||
|
||||
unsigned short len; /* Length of received Rx packet */
|
||||
|
||||
unsigned int interrupt; /* Interrupt indicator */
|
||||
|
||||
unsigned int mapped_as_page;
|
||||
|
||||
/* Incomplete receive save location. If the budget is exhausted
|
||||
* or the last descriptor (last normal descriptor or a following
|
||||
* context descriptor) has not been DMA'd yet the current state
|
||||
* of the receive processing needs to be saved.
|
||||
*/
|
||||
unsigned int state_saved;
|
||||
struct {
|
||||
unsigned int incomplete;
|
||||
unsigned int context_next;
|
||||
struct sk_buff *skb;
|
||||
unsigned int len;
|
||||
unsigned int error;
|
||||
} state;
|
||||
};
|
||||
|
||||
struct xgbe_ring {
|
||||
/* Ring lock - used just for TX rings at the moment */
|
||||
spinlock_t lock;
|
||||
|
||||
/* Per packet related information */
|
||||
struct xgbe_packet_data packet_data;
|
||||
|
||||
/* Virtual/DMA addresses and count of allocated descriptor memory */
|
||||
struct xgbe_ring_desc *rdesc;
|
||||
dma_addr_t rdesc_dma;
|
||||
unsigned int rdesc_count;
|
||||
|
||||
/* Array of descriptor data corresponding the descriptor memory
|
||||
* (always use the XGBE_GET_DESC_DATA macro to access this data)
|
||||
*/
|
||||
struct xgbe_ring_data *rdata;
|
||||
|
||||
/* Ring index values
|
||||
* cur - Tx: index of descriptor to be used for current transfer
|
||||
* Rx: index of descriptor to check for packet availability
|
||||
* dirty - Tx: index of descriptor to check for transfer complete
|
||||
* Rx: count of descriptors in which a packet has been received
|
||||
* (used with skb_realloc_index to refresh the ring)
|
||||
*/
|
||||
unsigned int cur;
|
||||
unsigned int dirty;
|
||||
|
||||
/* Coalesce frame count used for interrupt bit setting */
|
||||
unsigned int coalesce_count;
|
||||
|
||||
union {
|
||||
struct {
|
||||
unsigned int queue_stopped;
|
||||
unsigned short cur_mss;
|
||||
unsigned short cur_vlan_ctag;
|
||||
} tx;
|
||||
|
||||
struct {
|
||||
unsigned int realloc_index;
|
||||
unsigned int realloc_threshold;
|
||||
} rx;
|
||||
};
|
||||
} ____cacheline_aligned;
|
||||
|
||||
/* Structure used to describe the descriptor rings associated with
|
||||
* a DMA channel.
|
||||
*/
|
||||
struct xgbe_channel {
|
||||
char name[16];
|
||||
|
||||
/* Address of private data area for device */
|
||||
struct xgbe_prv_data *pdata;
|
||||
|
||||
/* Queue index and base address of queue's DMA registers */
|
||||
unsigned int queue_index;
|
||||
void __iomem *dma_regs;
|
||||
|
||||
unsigned int saved_ier;
|
||||
|
||||
unsigned int tx_timer_active;
|
||||
struct hrtimer tx_timer;
|
||||
|
||||
struct xgbe_ring *tx_ring;
|
||||
struct xgbe_ring *rx_ring;
|
||||
} ____cacheline_aligned;
|
||||
|
||||
enum xgbe_int {
|
||||
XGMAC_INT_DMA_CH_SR_TI,
|
||||
XGMAC_INT_DMA_CH_SR_TPS,
|
||||
XGMAC_INT_DMA_CH_SR_TBU,
|
||||
XGMAC_INT_DMA_CH_SR_RI,
|
||||
XGMAC_INT_DMA_CH_SR_RBU,
|
||||
XGMAC_INT_DMA_CH_SR_RPS,
|
||||
XGMAC_INT_DMA_CH_SR_TI_RI,
|
||||
XGMAC_INT_DMA_CH_SR_FBE,
|
||||
XGMAC_INT_DMA_ALL,
|
||||
};
|
||||
|
||||
enum xgbe_int_state {
|
||||
XGMAC_INT_STATE_SAVE,
|
||||
XGMAC_INT_STATE_RESTORE,
|
||||
};
|
||||
|
||||
enum xgbe_mtl_fifo_size {
|
||||
XGMAC_MTL_FIFO_SIZE_256 = 0x00,
|
||||
XGMAC_MTL_FIFO_SIZE_512 = 0x01,
|
||||
XGMAC_MTL_FIFO_SIZE_1K = 0x03,
|
||||
XGMAC_MTL_FIFO_SIZE_2K = 0x07,
|
||||
XGMAC_MTL_FIFO_SIZE_4K = 0x0f,
|
||||
XGMAC_MTL_FIFO_SIZE_8K = 0x1f,
|
||||
XGMAC_MTL_FIFO_SIZE_16K = 0x3f,
|
||||
XGMAC_MTL_FIFO_SIZE_32K = 0x7f,
|
||||
XGMAC_MTL_FIFO_SIZE_64K = 0xff,
|
||||
XGMAC_MTL_FIFO_SIZE_128K = 0x1ff,
|
||||
XGMAC_MTL_FIFO_SIZE_256K = 0x3ff,
|
||||
};
|
||||
|
||||
struct xgbe_mmc_stats {
|
||||
/* Tx Stats */
|
||||
u64 txoctetcount_gb;
|
||||
u64 txframecount_gb;
|
||||
u64 txbroadcastframes_g;
|
||||
u64 txmulticastframes_g;
|
||||
u64 tx64octets_gb;
|
||||
u64 tx65to127octets_gb;
|
||||
u64 tx128to255octets_gb;
|
||||
u64 tx256to511octets_gb;
|
||||
u64 tx512to1023octets_gb;
|
||||
u64 tx1024tomaxoctets_gb;
|
||||
u64 txunicastframes_gb;
|
||||
u64 txmulticastframes_gb;
|
||||
u64 txbroadcastframes_gb;
|
||||
u64 txunderflowerror;
|
||||
u64 txoctetcount_g;
|
||||
u64 txframecount_g;
|
||||
u64 txpauseframes;
|
||||
u64 txvlanframes_g;
|
||||
|
||||
/* Rx Stats */
|
||||
u64 rxframecount_gb;
|
||||
u64 rxoctetcount_gb;
|
||||
u64 rxoctetcount_g;
|
||||
u64 rxbroadcastframes_g;
|
||||
u64 rxmulticastframes_g;
|
||||
u64 rxcrcerror;
|
||||
u64 rxrunterror;
|
||||
u64 rxjabbererror;
|
||||
u64 rxundersize_g;
|
||||
u64 rxoversize_g;
|
||||
u64 rx64octets_gb;
|
||||
u64 rx65to127octets_gb;
|
||||
u64 rx128to255octets_gb;
|
||||
u64 rx256to511octets_gb;
|
||||
u64 rx512to1023octets_gb;
|
||||
u64 rx1024tomaxoctets_gb;
|
||||
u64 rxunicastframes_g;
|
||||
u64 rxlengtherror;
|
||||
u64 rxoutofrangetype;
|
||||
u64 rxpauseframes;
|
||||
u64 rxfifooverflow;
|
||||
u64 rxvlanframes_gb;
|
||||
u64 rxwatchdogerror;
|
||||
};
|
||||
|
||||
struct xgbe_hw_if {
|
||||
int (*tx_complete)(struct xgbe_ring_desc *);
|
||||
|
||||
int (*set_promiscuous_mode)(struct xgbe_prv_data *, unsigned int);
|
||||
int (*set_all_multicast_mode)(struct xgbe_prv_data *, unsigned int);
|
||||
int (*add_mac_addresses)(struct xgbe_prv_data *);
|
||||
int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr);
|
||||
|
||||
int (*enable_rx_csum)(struct xgbe_prv_data *);
|
||||
int (*disable_rx_csum)(struct xgbe_prv_data *);
|
||||
|
||||
int (*enable_rx_vlan_stripping)(struct xgbe_prv_data *);
|
||||
int (*disable_rx_vlan_stripping)(struct xgbe_prv_data *);
|
||||
int (*enable_rx_vlan_filtering)(struct xgbe_prv_data *);
|
||||
int (*disable_rx_vlan_filtering)(struct xgbe_prv_data *);
|
||||
int (*update_vlan_hash_table)(struct xgbe_prv_data *);
|
||||
|
||||
int (*read_mmd_regs)(struct xgbe_prv_data *, int, int);
|
||||
void (*write_mmd_regs)(struct xgbe_prv_data *, int, int, int);
|
||||
int (*set_gmii_speed)(struct xgbe_prv_data *);
|
||||
int (*set_gmii_2500_speed)(struct xgbe_prv_data *);
|
||||
int (*set_xgmii_speed)(struct xgbe_prv_data *);
|
||||
|
||||
void (*enable_tx)(struct xgbe_prv_data *);
|
||||
void (*disable_tx)(struct xgbe_prv_data *);
|
||||
void (*enable_rx)(struct xgbe_prv_data *);
|
||||
void (*disable_rx)(struct xgbe_prv_data *);
|
||||
|
||||
void (*powerup_tx)(struct xgbe_prv_data *);
|
||||
void (*powerdown_tx)(struct xgbe_prv_data *);
|
||||
void (*powerup_rx)(struct xgbe_prv_data *);
|
||||
void (*powerdown_rx)(struct xgbe_prv_data *);
|
||||
|
||||
int (*init)(struct xgbe_prv_data *);
|
||||
int (*exit)(struct xgbe_prv_data *);
|
||||
|
||||
int (*enable_int)(struct xgbe_channel *, enum xgbe_int);
|
||||
int (*disable_int)(struct xgbe_channel *, enum xgbe_int);
|
||||
void (*pre_xmit)(struct xgbe_channel *);
|
||||
int (*dev_read)(struct xgbe_channel *);
|
||||
void (*tx_desc_init)(struct xgbe_channel *);
|
||||
void (*rx_desc_init)(struct xgbe_channel *);
|
||||
void (*rx_desc_reset)(struct xgbe_ring_data *);
|
||||
void (*tx_desc_reset)(struct xgbe_ring_data *);
|
||||
int (*is_last_desc)(struct xgbe_ring_desc *);
|
||||
int (*is_context_desc)(struct xgbe_ring_desc *);
|
||||
|
||||
/* For FLOW ctrl */
|
||||
int (*config_tx_flow_control)(struct xgbe_prv_data *);
|
||||
int (*config_rx_flow_control)(struct xgbe_prv_data *);
|
||||
|
||||
/* For RX coalescing */
|
||||
int (*config_rx_coalesce)(struct xgbe_prv_data *);
|
||||
int (*config_tx_coalesce)(struct xgbe_prv_data *);
|
||||
unsigned int (*usec_to_riwt)(struct xgbe_prv_data *, unsigned int);
|
||||
unsigned int (*riwt_to_usec)(struct xgbe_prv_data *, unsigned int);
|
||||
|
||||
/* For RX and TX threshold config */
|
||||
int (*config_rx_threshold)(struct xgbe_prv_data *, unsigned int);
|
||||
int (*config_tx_threshold)(struct xgbe_prv_data *, unsigned int);
|
||||
|
||||
/* For RX and TX Store and Forward Mode config */
|
||||
int (*config_rsf_mode)(struct xgbe_prv_data *, unsigned int);
|
||||
int (*config_tsf_mode)(struct xgbe_prv_data *, unsigned int);
|
||||
|
||||
/* For TX DMA Operate on Second Frame config */
|
||||
int (*config_osp_mode)(struct xgbe_prv_data *);
|
||||
|
||||
/* For RX and TX PBL config */
|
||||
int (*config_rx_pbl_val)(struct xgbe_prv_data *);
|
||||
int (*get_rx_pbl_val)(struct xgbe_prv_data *);
|
||||
int (*config_tx_pbl_val)(struct xgbe_prv_data *);
|
||||
int (*get_tx_pbl_val)(struct xgbe_prv_data *);
|
||||
int (*config_pblx8)(struct xgbe_prv_data *);
|
||||
|
||||
/* For MMC statistics */
|
||||
void (*rx_mmc_int)(struct xgbe_prv_data *);
|
||||
void (*tx_mmc_int)(struct xgbe_prv_data *);
|
||||
void (*read_mmc_stats)(struct xgbe_prv_data *);
|
||||
|
||||
/* For Timestamp config */
|
||||
int (*config_tstamp)(struct xgbe_prv_data *, unsigned int);
|
||||
void (*update_tstamp_addend)(struct xgbe_prv_data *, unsigned int);
|
||||
void (*set_tstamp_time)(struct xgbe_prv_data *, unsigned int sec,
|
||||
unsigned int nsec);
|
||||
u64 (*get_tstamp_time)(struct xgbe_prv_data *);
|
||||
u64 (*get_tx_tstamp)(struct xgbe_prv_data *);
|
||||
|
||||
/* For Data Center Bridging config */
|
||||
void (*config_dcb_tc)(struct xgbe_prv_data *);
|
||||
void (*config_dcb_pfc)(struct xgbe_prv_data *);
|
||||
};
|
||||
|
||||
struct xgbe_desc_if {
|
||||
int (*alloc_ring_resources)(struct xgbe_prv_data *);
|
||||
void (*free_ring_resources)(struct xgbe_prv_data *);
|
||||
int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *);
|
||||
void (*realloc_skb)(struct xgbe_channel *);
|
||||
void (*unmap_skb)(struct xgbe_prv_data *, struct xgbe_ring_data *);
|
||||
void (*wrapper_tx_desc_init)(struct xgbe_prv_data *);
|
||||
void (*wrapper_rx_desc_init)(struct xgbe_prv_data *);
|
||||
};
|
||||
|
||||
/* This structure contains flags that indicate what hardware features
|
||||
* or configurations are present in the device.
|
||||
*/
|
||||
struct xgbe_hw_features {
|
||||
/* HW Version */
|
||||
unsigned int version;
|
||||
|
||||
/* HW Feature Register0 */
|
||||
unsigned int gmii; /* 1000 Mbps support */
|
||||
unsigned int vlhash; /* VLAN Hash Filter */
|
||||
unsigned int sma; /* SMA(MDIO) Interface */
|
||||
unsigned int rwk; /* PMT remote wake-up packet */
|
||||
unsigned int mgk; /* PMT magic packet */
|
||||
unsigned int mmc; /* RMON module */
|
||||
unsigned int aoe; /* ARP Offload */
|
||||
unsigned int ts; /* IEEE 1588-2008 Adavanced Timestamp */
|
||||
unsigned int eee; /* Energy Efficient Ethernet */
|
||||
unsigned int tx_coe; /* Tx Checksum Offload */
|
||||
unsigned int rx_coe; /* Rx Checksum Offload */
|
||||
unsigned int addn_mac; /* Additional MAC Addresses */
|
||||
unsigned int ts_src; /* Timestamp Source */
|
||||
unsigned int sa_vlan_ins; /* Source Address or VLAN Insertion */
|
||||
|
||||
/* HW Feature Register1 */
|
||||
unsigned int rx_fifo_size; /* MTL Receive FIFO Size */
|
||||
unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */
|
||||
unsigned int adv_ts_hi; /* Advance Timestamping High Word */
|
||||
unsigned int dcb; /* DCB Feature */
|
||||
unsigned int sph; /* Split Header Feature */
|
||||
unsigned int tso; /* TCP Segmentation Offload */
|
||||
unsigned int dma_debug; /* DMA Debug Registers */
|
||||
unsigned int rss; /* Receive Side Scaling */
|
||||
unsigned int tc_cnt; /* Number of Traffic Classes */
|
||||
unsigned int hash_table_size; /* Hash Table Size */
|
||||
unsigned int l3l4_filter_num; /* Number of L3-L4 Filters */
|
||||
|
||||
/* HW Feature Register2 */
|
||||
unsigned int rx_q_cnt; /* Number of MTL Receive Queues */
|
||||
unsigned int tx_q_cnt; /* Number of MTL Transmit Queues */
|
||||
unsigned int rx_ch_cnt; /* Number of DMA Receive Channels */
|
||||
unsigned int tx_ch_cnt; /* Number of DMA Transmit Channels */
|
||||
unsigned int pps_out_num; /* Number of PPS outputs */
|
||||
unsigned int aux_snap_num; /* Number of Aux snapshot inputs */
|
||||
};
|
||||
|
||||
struct xgbe_prv_data {
|
||||
struct net_device *netdev;
|
||||
struct platform_device *pdev;
|
||||
struct device *dev;
|
||||
|
||||
/* XGMAC/XPCS related mmio registers */
|
||||
void __iomem *xgmac_regs; /* XGMAC CSRs */
|
||||
void __iomem *xpcs_regs; /* XPCS MMD registers */
|
||||
|
||||
/* Overall device lock */
|
||||
spinlock_t lock;
|
||||
|
||||
/* XPCS indirect addressing mutex */
|
||||
struct mutex xpcs_mutex;
|
||||
|
||||
int irq_number;
|
||||
|
||||
struct xgbe_hw_if hw_if;
|
||||
struct xgbe_desc_if desc_if;
|
||||
|
||||
/* AXI DMA settings */
|
||||
unsigned int axdomain;
|
||||
unsigned int arcache;
|
||||
unsigned int awcache;
|
||||
|
||||
/* Rings for Tx/Rx on a DMA channel */
|
||||
struct xgbe_channel *channel;
|
||||
unsigned int channel_count;
|
||||
unsigned int tx_ring_count;
|
||||
unsigned int tx_desc_count;
|
||||
unsigned int rx_ring_count;
|
||||
unsigned int rx_desc_count;
|
||||
|
||||
unsigned int tx_q_count;
|
||||
unsigned int rx_q_count;
|
||||
|
||||
/* Tx/Rx common settings */
|
||||
unsigned int pblx8;
|
||||
|
||||
/* Tx settings */
|
||||
unsigned int tx_sf_mode;
|
||||
unsigned int tx_threshold;
|
||||
unsigned int tx_pbl;
|
||||
unsigned int tx_osp_mode;
|
||||
|
||||
/* Rx settings */
|
||||
unsigned int rx_sf_mode;
|
||||
unsigned int rx_threshold;
|
||||
unsigned int rx_pbl;
|
||||
|
||||
/* Tx coalescing settings */
|
||||
unsigned int tx_usecs;
|
||||
unsigned int tx_frames;
|
||||
|
||||
/* Rx coalescing settings */
|
||||
unsigned int rx_riwt;
|
||||
unsigned int rx_frames;
|
||||
|
||||
/* Current MTU */
|
||||
unsigned int rx_buf_size;
|
||||
|
||||
/* Flow control settings */
|
||||
unsigned int pause_autoneg;
|
||||
unsigned int tx_pause;
|
||||
unsigned int rx_pause;
|
||||
|
||||
/* MDIO settings */
|
||||
struct module *phy_module;
|
||||
char *mii_bus_id;
|
||||
struct mii_bus *mii;
|
||||
int mdio_mmd;
|
||||
struct phy_device *phydev;
|
||||
int default_autoneg;
|
||||
int default_speed;
|
||||
|
||||
/* Current PHY settings */
|
||||
phy_interface_t phy_mode;
|
||||
int phy_link;
|
||||
int phy_speed;
|
||||
unsigned int phy_tx_pause;
|
||||
unsigned int phy_rx_pause;
|
||||
|
||||
/* Netdev related settings */
|
||||
netdev_features_t netdev_features;
|
||||
struct napi_struct napi;
|
||||
struct xgbe_mmc_stats mmc_stats;
|
||||
|
||||
/* Filtering support */
|
||||
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
|
||||
|
||||
/* Device clocks */
|
||||
struct clk *sysclk;
|
||||
struct clk *ptpclk;
|
||||
|
||||
/* Timestamp support */
|
||||
spinlock_t tstamp_lock;
|
||||
struct ptp_clock_info ptp_clock_info;
|
||||
struct ptp_clock *ptp_clock;
|
||||
struct hwtstamp_config tstamp_config;
|
||||
struct cyclecounter tstamp_cc;
|
||||
struct timecounter tstamp_tc;
|
||||
unsigned int tstamp_addend;
|
||||
struct work_struct tx_tstamp_work;
|
||||
struct sk_buff *tx_tstamp_skb;
|
||||
u64 tx_tstamp;
|
||||
|
||||
/* DCB support */
|
||||
struct ieee_ets *ets;
|
||||
struct ieee_pfc *pfc;
|
||||
unsigned int q2tc_map[XGBE_MAX_QUEUES];
|
||||
unsigned int prio2q_map[IEEE_8021QAZ_MAX_TCS];
|
||||
|
||||
/* Hardware features of the device */
|
||||
struct xgbe_hw_features hw_feat;
|
||||
|
||||
/* Device restart work structure */
|
||||
struct work_struct restart_work;
|
||||
|
||||
/* Keeps track of power mode */
|
||||
unsigned int power_down;
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
struct dentry *xgbe_debugfs;
|
||||
|
||||
unsigned int debugfs_xgmac_reg;
|
||||
|
||||
unsigned int debugfs_xpcs_mmd;
|
||||
unsigned int debugfs_xpcs_reg;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Function prototypes*/
|
||||
|
||||
void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
|
||||
void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *);
|
||||
struct net_device_ops *xgbe_get_netdev_ops(void);
|
||||
struct ethtool_ops *xgbe_get_ethtool_ops(void);
|
||||
#ifdef CONFIG_AMD_XGBE_DCB
|
||||
const struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void);
|
||||
#endif
|
||||
|
||||
int xgbe_mdio_register(struct xgbe_prv_data *);
|
||||
void xgbe_mdio_unregister(struct xgbe_prv_data *);
|
||||
void xgbe_dump_phy_registers(struct xgbe_prv_data *);
|
||||
void xgbe_ptp_register(struct xgbe_prv_data *);
|
||||
void xgbe_ptp_unregister(struct xgbe_prv_data *);
|
||||
void xgbe_dump_tx_desc(struct xgbe_ring *, unsigned int, unsigned int,
|
||||
unsigned int);
|
||||
void xgbe_dump_rx_desc(struct xgbe_ring *, struct xgbe_ring_desc *,
|
||||
unsigned int);
|
||||
void xgbe_print_pkt(struct net_device *, struct sk_buff *, bool);
|
||||
void xgbe_get_all_hw_features(struct xgbe_prv_data *);
|
||||
int xgbe_powerup(struct net_device *, unsigned int);
|
||||
int xgbe_powerdown(struct net_device *, unsigned int);
|
||||
void xgbe_init_rx_coalesce(struct xgbe_prv_data *);
|
||||
void xgbe_init_tx_coalesce(struct xgbe_prv_data *);
|
||||
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
void xgbe_debugfs_init(struct xgbe_prv_data *);
|
||||
void xgbe_debugfs_exit(struct xgbe_prv_data *);
|
||||
#else
|
||||
static inline void xgbe_debugfs_init(struct xgbe_prv_data *pdata) {}
|
||||
static inline void xgbe_debugfs_exit(struct xgbe_prv_data *pdata) {}
|
||||
#endif /* CONFIG_DEBUG_FS */
|
||||
|
||||
/* NOTE: Uncomment for TX and RX DESCRIPTOR DUMP in KERNEL LOG */
|
||||
#if 0
|
||||
#define XGMAC_ENABLE_TX_DESC_DUMP
|
||||
#define XGMAC_ENABLE_RX_DESC_DUMP
|
||||
#endif
|
||||
|
||||
/* NOTE: Uncomment for TX and RX PACKET DUMP in KERNEL LOG */
|
||||
#if 0
|
||||
#define XGMAC_ENABLE_TX_PKT_DUMP
|
||||
#define XGMAC_ENABLE_RX_PKT_DUMP
|
||||
#endif
|
||||
|
||||
/* NOTE: Uncomment for function trace log messages in KERNEL LOG */
|
||||
#if 0
|
||||
#define YDEBUG
|
||||
#define YDEBUG_MDIO
|
||||
#endif
|
||||
|
||||
/* For debug prints */
|
||||
#ifdef YDEBUG
|
||||
#define DBGPR(x...) pr_alert(x)
|
||||
#define DBGPHY_REGS(x...) xgbe_dump_phy_registers(x)
|
||||
#else
|
||||
#define DBGPR(x...) do { } while (0)
|
||||
#define DBGPHY_REGS(x...) do { } while (0)
|
||||
#endif
|
||||
|
||||
#ifdef YDEBUG_MDIO
|
||||
#define DBGPR_MDIO(x...) pr_alert(x)
|
||||
#else
|
||||
#define DBGPR_MDIO(x...) do { } while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue