xref: /freebsd/sys/dev/axgbe/xgbe-drv.c (revision 685dc743dc3b5645e34836464128e1c0558b404b)
144b781cfSAndrew Turner /*
244b781cfSAndrew Turner  * AMD 10Gb Ethernet driver
344b781cfSAndrew Turner  *
47113afc8SEmmanuel Vadot  * Copyright (c) 2014-2016,2020 Advanced Micro Devices, Inc.
57113afc8SEmmanuel Vadot  *
644b781cfSAndrew Turner  * This file is available to you under your choice of the following two
744b781cfSAndrew Turner  * licenses:
844b781cfSAndrew Turner  *
944b781cfSAndrew Turner  * License 1: GPLv2
1044b781cfSAndrew Turner  *
1144b781cfSAndrew Turner  * This file is free software; you may copy, redistribute and/or modify
1244b781cfSAndrew Turner  * it under the terms of the GNU General Public License as published by
1344b781cfSAndrew Turner  * the Free Software Foundation, either version 2 of the License, or (at
1444b781cfSAndrew Turner  * your option) any later version.
1544b781cfSAndrew Turner  *
1644b781cfSAndrew Turner  * This file is distributed in the hope that it will be useful, but
1744b781cfSAndrew Turner  * WITHOUT ANY WARRANTY; without even the implied warranty of
1844b781cfSAndrew Turner  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1944b781cfSAndrew Turner  * General Public License for more details.
2044b781cfSAndrew Turner  *
2144b781cfSAndrew Turner  * You should have received a copy of the GNU General Public License
2244b781cfSAndrew Turner  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
2344b781cfSAndrew Turner  *
2444b781cfSAndrew Turner  * This file incorporates work covered by the following copyright and
2544b781cfSAndrew Turner  * permission notice:
2644b781cfSAndrew Turner  *     The Synopsys DWC ETHER XGMAC Software Driver and documentation
2744b781cfSAndrew Turner  *     (hereinafter "Software") is an unsupported proprietary work of Synopsys,
2844b781cfSAndrew Turner  *     Inc. unless otherwise expressly agreed to in writing between Synopsys
2944b781cfSAndrew Turner  *     and you.
3044b781cfSAndrew Turner  *
3144b781cfSAndrew Turner  *     The Software IS NOT an item of Licensed Software or Licensed Product
3244b781cfSAndrew Turner  *     under any End User Software License Agreement or Agreement for Licensed
3344b781cfSAndrew Turner  *     Product with Synopsys or any supplement thereto.  Permission is hereby
3444b781cfSAndrew Turner  *     granted, free of charge, to any person obtaining a copy of this software
3544b781cfSAndrew Turner  *     annotated with this license and the Software, to deal in the Software
3644b781cfSAndrew Turner  *     without restriction, including without limitation the rights to use,
3744b781cfSAndrew Turner  *     copy, modify, merge, publish, distribute, sublicense, and/or sell copies
3844b781cfSAndrew Turner  *     of the Software, and to permit persons to whom the Software is furnished
3944b781cfSAndrew Turner  *     to do so, subject to the following conditions:
4044b781cfSAndrew Turner  *
4144b781cfSAndrew Turner  *     The above copyright notice and this permission notice shall be included
4244b781cfSAndrew Turner  *     in all copies or substantial portions of the Software.
4344b781cfSAndrew Turner  *
4444b781cfSAndrew Turner  *     THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
4544b781cfSAndrew Turner  *     BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
4644b781cfSAndrew Turner  *     TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
4744b781cfSAndrew Turner  *     PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
4844b781cfSAndrew Turner  *     BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4944b781cfSAndrew Turner  *     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5044b781cfSAndrew Turner  *     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5144b781cfSAndrew Turner  *     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5244b781cfSAndrew Turner  *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5344b781cfSAndrew Turner  *     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
5444b781cfSAndrew Turner  *     THE POSSIBILITY OF SUCH DAMAGE.
5544b781cfSAndrew Turner  *
5644b781cfSAndrew Turner  *
5744b781cfSAndrew Turner  * License 2: Modified BSD
5844b781cfSAndrew Turner  *
5944b781cfSAndrew Turner  * Redistribution and use in source and binary forms, with or without
6044b781cfSAndrew Turner  * modification, are permitted provided that the following conditions are met:
6144b781cfSAndrew Turner  *     * Redistributions of source code must retain the above copyright
6244b781cfSAndrew Turner  *       notice, this list of conditions and the following disclaimer.
6344b781cfSAndrew Turner  *     * Redistributions in binary form must reproduce the above copyright
6444b781cfSAndrew Turner  *       notice, this list of conditions and the following disclaimer in the
6544b781cfSAndrew Turner  *       documentation and/or other materials provided with the distribution.
6644b781cfSAndrew Turner  *     * Neither the name of Advanced Micro Devices, Inc. nor the
6744b781cfSAndrew Turner  *       names of its contributors may be used to endorse or promote products
6844b781cfSAndrew Turner  *       derived from this software without specific prior written permission.
6944b781cfSAndrew Turner  *
7044b781cfSAndrew Turner  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
7144b781cfSAndrew Turner  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7244b781cfSAndrew Turner  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7344b781cfSAndrew Turner  * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
7444b781cfSAndrew Turner  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
7544b781cfSAndrew Turner  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
7644b781cfSAndrew Turner  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
7744b781cfSAndrew Turner  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
7844b781cfSAndrew Turner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
7944b781cfSAndrew Turner  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8044b781cfSAndrew Turner  *
8144b781cfSAndrew Turner  * This file incorporates work covered by the following copyright and
8244b781cfSAndrew Turner  * permission notice:
8344b781cfSAndrew Turner  *     The Synopsys DWC ETHER XGMAC Software Driver and documentation
8444b781cfSAndrew Turner  *     (hereinafter "Software") is an unsupported proprietary work of Synopsys,
8544b781cfSAndrew Turner  *     Inc. unless otherwise expressly agreed to in writing between Synopsys
8644b781cfSAndrew Turner  *     and you.
8744b781cfSAndrew Turner  *
8844b781cfSAndrew Turner  *     The Software IS NOT an item of Licensed Software or Licensed Product
8944b781cfSAndrew Turner  *     under any End User Software License Agreement or Agreement for Licensed
9044b781cfSAndrew Turner  *     Product with Synopsys or any supplement thereto.  Permission is hereby
9144b781cfSAndrew Turner  *     granted, free of charge, to any person obtaining a copy of this software
9244b781cfSAndrew Turner  *     annotated with this license and the Software, to deal in the Software
9344b781cfSAndrew Turner  *     without restriction, including without limitation the rights to use,
9444b781cfSAndrew Turner  *     copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9544b781cfSAndrew Turner  *     of the Software, and to permit persons to whom the Software is furnished
9644b781cfSAndrew Turner  *     to do so, subject to the following conditions:
9744b781cfSAndrew Turner  *
9844b781cfSAndrew Turner  *     The above copyright notice and this permission notice shall be included
9944b781cfSAndrew Turner  *     in all copies or substantial portions of the Software.
10044b781cfSAndrew Turner  *
10144b781cfSAndrew Turner  *     THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
10244b781cfSAndrew Turner  *     BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
10344b781cfSAndrew Turner  *     TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
10444b781cfSAndrew Turner  *     PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
10544b781cfSAndrew Turner  *     BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
10644b781cfSAndrew Turner  *     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
10744b781cfSAndrew Turner  *     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
10844b781cfSAndrew Turner  *     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
10944b781cfSAndrew Turner  *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
11044b781cfSAndrew Turner  *     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
11144b781cfSAndrew Turner  *     THE POSSIBILITY OF SUCH DAMAGE.
11244b781cfSAndrew Turner  */
11344b781cfSAndrew Turner 
1149c6d6488SAndrew Turner #include <sys/cdefs.h>
11544b781cfSAndrew Turner #include "xgbe.h"
11644b781cfSAndrew Turner #include "xgbe-common.h"
11744b781cfSAndrew Turner 
1187113afc8SEmmanuel Vadot int
xgbe_calc_rx_buf_size(if_t netdev,unsigned int mtu)119*402810d3SJustin Hibbits xgbe_calc_rx_buf_size(if_t netdev, unsigned int mtu)
12044b781cfSAndrew Turner {
12144b781cfSAndrew Turner 	unsigned int rx_buf_size;
12244b781cfSAndrew Turner 
1237113afc8SEmmanuel Vadot 	if (mtu > XGMAC_JUMBO_PACKET_MTU)
1247113afc8SEmmanuel Vadot 		return (-EINVAL);
12544b781cfSAndrew Turner 
12644b781cfSAndrew Turner 	rx_buf_size = mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
1277113afc8SEmmanuel Vadot 	rx_buf_size = min(max(rx_buf_size, XGBE_RX_MIN_BUF_SIZE), PAGE_SIZE);
12844b781cfSAndrew Turner 	rx_buf_size = (rx_buf_size + XGBE_RX_BUF_ALIGN - 1) &
12944b781cfSAndrew Turner 	    ~(XGBE_RX_BUF_ALIGN - 1);
13044b781cfSAndrew Turner 
1317113afc8SEmmanuel Vadot 	return (rx_buf_size);
13244b781cfSAndrew Turner }
13344b781cfSAndrew Turner 
1347113afc8SEmmanuel Vadot void
xgbe_get_all_hw_features(struct xgbe_prv_data * pdata)1357113afc8SEmmanuel Vadot xgbe_get_all_hw_features(struct xgbe_prv_data *pdata)
13644b781cfSAndrew Turner {
13744b781cfSAndrew Turner 	unsigned int mac_hfr0, mac_hfr1, mac_hfr2;
13844b781cfSAndrew Turner 	struct xgbe_hw_features *hw_feat = &pdata->hw_feat;
13944b781cfSAndrew Turner 
14044b781cfSAndrew Turner 	DBGPR("-->xgbe_get_all_hw_features\n");
14144b781cfSAndrew Turner 
14244b781cfSAndrew Turner 	mac_hfr0 = XGMAC_IOREAD(pdata, MAC_HWF0R);
14344b781cfSAndrew Turner 	mac_hfr1 = XGMAC_IOREAD(pdata, MAC_HWF1R);
14444b781cfSAndrew Turner 	mac_hfr2 = XGMAC_IOREAD(pdata, MAC_HWF2R);
14544b781cfSAndrew Turner 
14644b781cfSAndrew Turner 	memset(hw_feat, 0, sizeof(*hw_feat));
14744b781cfSAndrew Turner 
14844b781cfSAndrew Turner 	hw_feat->version = XGMAC_IOREAD(pdata, MAC_VR);
14944b781cfSAndrew Turner 
15044b781cfSAndrew Turner 	/* Hardware feature register 0 */
15144b781cfSAndrew Turner 	hw_feat->gmii	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, GMIISEL);
15244b781cfSAndrew Turner 	hw_feat->vlhash	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, VLHASH);
15344b781cfSAndrew Turner 	hw_feat->sma	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, SMASEL);
15444b781cfSAndrew Turner 	hw_feat->rwk	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, RWKSEL);
15544b781cfSAndrew Turner 	hw_feat->mgk	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, MGKSEL);
15644b781cfSAndrew Turner 	hw_feat->mmc	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, MMCSEL);
15744b781cfSAndrew Turner 	hw_feat->aoe	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, ARPOFFSEL);
15844b781cfSAndrew Turner 	hw_feat->ts	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TSSEL);
15944b781cfSAndrew Turner 	hw_feat->eee	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, EEESEL);
16044b781cfSAndrew Turner 	hw_feat->tx_coe	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TXCOESEL);
16144b781cfSAndrew Turner 	hw_feat->rx_coe	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, RXCOESEL);
16244b781cfSAndrew Turner 	hw_feat->addn_mac = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R,
16344b781cfSAndrew Turner 					      ADDMACADRSEL);
16444b781cfSAndrew Turner 	hw_feat->ts_src	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, TSSTSSEL);
16544b781cfSAndrew Turner 	hw_feat->sa_vlan_ins = XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, SAVLANINS);
1667113afc8SEmmanuel Vadot 	hw_feat->vxn	= XGMAC_GET_BITS(mac_hfr0, MAC_HWF0R, VXN);
16744b781cfSAndrew Turner 
16844b781cfSAndrew Turner 	/* Hardware feature register 1 */
16944b781cfSAndrew Turner 	hw_feat->rx_fifo_size	= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R,
17044b781cfSAndrew Turner 						RXFIFOSIZE);
17144b781cfSAndrew Turner 	hw_feat->tx_fifo_size	= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R,
17244b781cfSAndrew Turner 						TXFIFOSIZE);
17344b781cfSAndrew Turner 	hw_feat->adv_ts_hi	= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, ADVTHWORD);
17444b781cfSAndrew Turner 	hw_feat->dma_width	= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, ADDR64);
17544b781cfSAndrew Turner 	hw_feat->dcb		= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DCBEN);
17644b781cfSAndrew Turner 	hw_feat->sph		= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, SPHEN);
17744b781cfSAndrew Turner 	hw_feat->tso		= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, TSOEN);
17844b781cfSAndrew Turner 	hw_feat->dma_debug	= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DBGMEMA);
17944b781cfSAndrew Turner 	hw_feat->rss		= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, RSSEN);
18044b781cfSAndrew Turner 	hw_feat->tc_cnt		= XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, NUMTC);
18144b781cfSAndrew Turner 	hw_feat->hash_table_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R,
18244b781cfSAndrew Turner 						  HASHTBLSZ);
18344b781cfSAndrew Turner 	hw_feat->l3l4_filter_num = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R,
18444b781cfSAndrew Turner 						  L3L4FNUM);
18544b781cfSAndrew Turner 
18644b781cfSAndrew Turner 	/* Hardware feature register 2 */
18744b781cfSAndrew Turner 	hw_feat->rx_q_cnt     = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, RXQCNT);
18844b781cfSAndrew Turner 	hw_feat->tx_q_cnt     = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, TXQCNT);
18944b781cfSAndrew Turner 	hw_feat->rx_ch_cnt    = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, RXCHCNT);
19044b781cfSAndrew Turner 	hw_feat->tx_ch_cnt    = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, TXCHCNT);
19144b781cfSAndrew Turner 	hw_feat->pps_out_num  = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, PPSOUTNUM);
19244b781cfSAndrew Turner 	hw_feat->aux_snap_num = XGMAC_GET_BITS(mac_hfr2, MAC_HWF2R, AUXSNAPNUM);
19344b781cfSAndrew Turner 
19444b781cfSAndrew Turner 	/* Translate the Hash Table size into actual number */
19544b781cfSAndrew Turner 	switch (hw_feat->hash_table_size) {
19644b781cfSAndrew Turner 	case 0:
19744b781cfSAndrew Turner 		break;
19844b781cfSAndrew Turner 	case 1:
19944b781cfSAndrew Turner 		hw_feat->hash_table_size = 64;
20044b781cfSAndrew Turner 		break;
20144b781cfSAndrew Turner 	case 2:
20244b781cfSAndrew Turner 		hw_feat->hash_table_size = 128;
20344b781cfSAndrew Turner 		break;
20444b781cfSAndrew Turner 	case 3:
20544b781cfSAndrew Turner 		hw_feat->hash_table_size = 256;
20644b781cfSAndrew Turner 		break;
20744b781cfSAndrew Turner 	}
20844b781cfSAndrew Turner 
20944b781cfSAndrew Turner 	/* Translate the address width setting into actual number */
21044b781cfSAndrew Turner 	switch (hw_feat->dma_width) {
21144b781cfSAndrew Turner 	case 0:
21244b781cfSAndrew Turner 		hw_feat->dma_width = 32;
21344b781cfSAndrew Turner 		break;
21444b781cfSAndrew Turner 	case 1:
21544b781cfSAndrew Turner 		hw_feat->dma_width = 40;
21644b781cfSAndrew Turner 		break;
21744b781cfSAndrew Turner 	case 2:
21844b781cfSAndrew Turner 		hw_feat->dma_width = 48;
21944b781cfSAndrew Turner 		break;
22044b781cfSAndrew Turner 	default:
22144b781cfSAndrew Turner 		hw_feat->dma_width = 32;
22244b781cfSAndrew Turner 	}
22344b781cfSAndrew Turner 
22444b781cfSAndrew Turner 	/* The Queue, Channel and TC counts are zero based so increment them
22544b781cfSAndrew Turner 	 * to get the actual number
22644b781cfSAndrew Turner 	 */
22744b781cfSAndrew Turner 	hw_feat->rx_q_cnt++;
22844b781cfSAndrew Turner 	hw_feat->tx_q_cnt++;
22944b781cfSAndrew Turner 	hw_feat->rx_ch_cnt++;
23044b781cfSAndrew Turner 	hw_feat->tx_ch_cnt++;
23144b781cfSAndrew Turner 	hw_feat->tc_cnt++;
23244b781cfSAndrew Turner 
2337113afc8SEmmanuel Vadot 	/* Translate the fifo sizes into actual numbers */
2347113afc8SEmmanuel Vadot 	hw_feat->rx_fifo_size = 1 << (hw_feat->rx_fifo_size + 7);
2357113afc8SEmmanuel Vadot 	hw_feat->tx_fifo_size = 1 << (hw_feat->tx_fifo_size + 7);
2367113afc8SEmmanuel Vadot 	DBGPR("%s: Tx fifo 0x%x Rx fifo 0x%x\n", __func__,
2377113afc8SEmmanuel Vadot 	    hw_feat->tx_fifo_size, hw_feat->rx_fifo_size);
2387113afc8SEmmanuel Vadot 
2397113afc8SEmmanuel Vadot 	DBGPR("Hardware features:\n");
2407113afc8SEmmanuel Vadot 
2417113afc8SEmmanuel Vadot 	/* Hardware feature register 0 */
2427113afc8SEmmanuel Vadot 	DBGPR("  1GbE support		   : %s\n",
2437113afc8SEmmanuel Vadot 	    hw_feat->gmii ? "yes" : "no");
2447113afc8SEmmanuel Vadot 	DBGPR("  VLAN hash filter	   : %s\n",
2457113afc8SEmmanuel Vadot 	    hw_feat->vlhash ? "yes" : "no");
2467113afc8SEmmanuel Vadot 	DBGPR("  MDIO interface		   : %s\n",
2477113afc8SEmmanuel Vadot 	    hw_feat->sma ? "yes" : "no");
2487113afc8SEmmanuel Vadot 	DBGPR("  Wake-up packet support    : %s\n",
2497113afc8SEmmanuel Vadot 	    hw_feat->rwk ? "yes" : "no");
2507113afc8SEmmanuel Vadot 	DBGPR("  Magic packet support      : %s\n",
2517113afc8SEmmanuel Vadot 	    hw_feat->mgk ? "yes" : "no");
2527113afc8SEmmanuel Vadot 	DBGPR("  Management counters       : %s\n",
2537113afc8SEmmanuel Vadot 	    hw_feat->mmc ? "yes" : "no");
2547113afc8SEmmanuel Vadot 	DBGPR("  ARP offload		   : %s\n",
2557113afc8SEmmanuel Vadot 	    hw_feat->aoe ? "yes" : "no");
2567113afc8SEmmanuel Vadot 	DBGPR("  IEEE 1588-2008 Timestamp  : %s\n",
2577113afc8SEmmanuel Vadot 	    hw_feat->ts ? "yes" : "no");
2587113afc8SEmmanuel Vadot 	DBGPR("  Energy Efficient Ethernet : %s\n",
2597113afc8SEmmanuel Vadot 	    hw_feat->eee ? "yes" : "no");
2607113afc8SEmmanuel Vadot 	DBGPR("  TX checksum offload       : %s\n",
2617113afc8SEmmanuel Vadot 	    hw_feat->tx_coe ? "yes" : "no");
2627113afc8SEmmanuel Vadot 	DBGPR("  RX checksum offload       : %s\n",
2637113afc8SEmmanuel Vadot 	    hw_feat->rx_coe ? "yes" : "no");
2647113afc8SEmmanuel Vadot 	DBGPR("  Additional MAC addresses  : %u\n",
2657113afc8SEmmanuel Vadot 	    hw_feat->addn_mac);
2667113afc8SEmmanuel Vadot 	DBGPR("  Timestamp source	   : %s\n",
2677113afc8SEmmanuel Vadot 	    (hw_feat->ts_src == 1) ? "internal" :
2687113afc8SEmmanuel Vadot 	    (hw_feat->ts_src == 2) ? "external" :
2697113afc8SEmmanuel Vadot 	    (hw_feat->ts_src == 3) ? "internal/external" : "n/a");
2707113afc8SEmmanuel Vadot 	DBGPR("  SA/VLAN insertion	   : %s\n",
2717113afc8SEmmanuel Vadot 	    hw_feat->sa_vlan_ins ? "yes" : "no");
2727113afc8SEmmanuel Vadot 
2737113afc8SEmmanuel Vadot 	/* Hardware feature register 1 */
2747113afc8SEmmanuel Vadot 	DBGPR("  RX fifo size		   : %u\n",
2757113afc8SEmmanuel Vadot 	    hw_feat->rx_fifo_size);
2767113afc8SEmmanuel Vadot 	DBGPR("  TX fifo size		   : %u\n",
2777113afc8SEmmanuel Vadot 	    hw_feat->tx_fifo_size);
2787113afc8SEmmanuel Vadot 	DBGPR("  IEEE 1588 high word       : %s\n",
2797113afc8SEmmanuel Vadot 	    hw_feat->adv_ts_hi ? "yes" : "no");
2807113afc8SEmmanuel Vadot 	DBGPR("  DMA width		   : %u\n",
2817113afc8SEmmanuel Vadot 	    hw_feat->dma_width);
2827113afc8SEmmanuel Vadot 	DBGPR("  Data Center Bridging      : %s\n",
2837113afc8SEmmanuel Vadot 	    hw_feat->dcb ? "yes" : "no");
2847113afc8SEmmanuel Vadot 	DBGPR("  Split header		   : %s\n",
2857113afc8SEmmanuel Vadot 	    hw_feat->sph ? "yes" : "no");
2867113afc8SEmmanuel Vadot 	DBGPR("  TCP Segmentation Offload  : %s\n",
2877113afc8SEmmanuel Vadot 	    hw_feat->tso ? "yes" : "no");
2887113afc8SEmmanuel Vadot 	DBGPR("  Debug memory interface    : %s\n",
2897113afc8SEmmanuel Vadot 	    hw_feat->dma_debug ? "yes" : "no");
2907113afc8SEmmanuel Vadot 	DBGPR("  Receive Side Scaling      : %s\n",
2917113afc8SEmmanuel Vadot 	    hw_feat->rss ? "yes" : "no");
2927113afc8SEmmanuel Vadot 	DBGPR("  Traffic Class count       : %u\n",
2937113afc8SEmmanuel Vadot 	    hw_feat->tc_cnt);
2947113afc8SEmmanuel Vadot 	DBGPR("  Hash table size	   : %u\n",
2957113afc8SEmmanuel Vadot 	    hw_feat->hash_table_size);
2967113afc8SEmmanuel Vadot 	DBGPR("  L3/L4 Filters		   : %u\n",
2977113afc8SEmmanuel Vadot 	    hw_feat->l3l4_filter_num);
2987113afc8SEmmanuel Vadot 
2997113afc8SEmmanuel Vadot 	/* Hardware feature register 2 */
3007113afc8SEmmanuel Vadot 	DBGPR("  RX queue count		   : %u\n",
3017113afc8SEmmanuel Vadot 	    hw_feat->rx_q_cnt);
3027113afc8SEmmanuel Vadot 	DBGPR("  TX queue count		   : %u\n",
3037113afc8SEmmanuel Vadot 	    hw_feat->tx_q_cnt);
3047113afc8SEmmanuel Vadot 	DBGPR("  RX DMA channel count      : %u\n",
3057113afc8SEmmanuel Vadot 	    hw_feat->rx_ch_cnt);
3067113afc8SEmmanuel Vadot 	DBGPR("  TX DMA channel count      : %u\n",
3077113afc8SEmmanuel Vadot 	    hw_feat->rx_ch_cnt);
3087113afc8SEmmanuel Vadot 	DBGPR("  PPS outputs		   : %u\n",
3097113afc8SEmmanuel Vadot 	    hw_feat->pps_out_num);
3107113afc8SEmmanuel Vadot 	DBGPR("  Auxiliary snapshot inputs : %u\n",
3117113afc8SEmmanuel Vadot 	    hw_feat->aux_snap_num);
3127113afc8SEmmanuel Vadot 
31344b781cfSAndrew Turner 	DBGPR("<--xgbe_get_all_hw_features\n");
31444b781cfSAndrew Turner }
31544b781cfSAndrew Turner 
3167113afc8SEmmanuel Vadot void
xgbe_init_tx_coalesce(struct xgbe_prv_data * pdata)3177113afc8SEmmanuel Vadot xgbe_init_tx_coalesce(struct xgbe_prv_data *pdata)
31844b781cfSAndrew Turner {
31944b781cfSAndrew Turner 	struct xgbe_hw_if *hw_if = &pdata->hw_if;
32044b781cfSAndrew Turner 
32144b781cfSAndrew Turner 	DBGPR("-->xgbe_init_tx_coalesce\n");
32244b781cfSAndrew Turner 
32344b781cfSAndrew Turner 	pdata->tx_usecs = XGMAC_INIT_DMA_TX_USECS;
32444b781cfSAndrew Turner 	pdata->tx_frames = XGMAC_INIT_DMA_TX_FRAMES;
32544b781cfSAndrew Turner 
32644b781cfSAndrew Turner 	hw_if->config_tx_coalesce(pdata);
32744b781cfSAndrew Turner 
32844b781cfSAndrew Turner 	DBGPR("<--xgbe_init_tx_coalesce\n");
32944b781cfSAndrew Turner }
33044b781cfSAndrew Turner 
3317113afc8SEmmanuel Vadot void
xgbe_init_rx_coalesce(struct xgbe_prv_data * pdata)3327113afc8SEmmanuel Vadot xgbe_init_rx_coalesce(struct xgbe_prv_data *pdata)
33344b781cfSAndrew Turner {
33444b781cfSAndrew Turner 	struct xgbe_hw_if *hw_if = &pdata->hw_if;
33544b781cfSAndrew Turner 
33644b781cfSAndrew Turner 	DBGPR("-->xgbe_init_rx_coalesce\n");
33744b781cfSAndrew Turner 
33844b781cfSAndrew Turner 	pdata->rx_riwt = hw_if->usec_to_riwt(pdata, XGMAC_INIT_DMA_RX_USECS);
33944b781cfSAndrew Turner 	pdata->rx_usecs = XGMAC_INIT_DMA_RX_USECS;
34044b781cfSAndrew Turner 	pdata->rx_frames = XGMAC_INIT_DMA_RX_FRAMES;
34144b781cfSAndrew Turner 
34244b781cfSAndrew Turner 	hw_if->config_rx_coalesce(pdata);
34344b781cfSAndrew Turner 
34444b781cfSAndrew Turner 	DBGPR("<--xgbe_init_rx_coalesce\n");
34544b781cfSAndrew Turner }
346