19573ed00SAndrew Rybchenko /*- 2929c7febSAndrew Rybchenko * Copyright (c) 2012-2016 Solarflare Communications Inc. 39573ed00SAndrew Rybchenko * All rights reserved. 49573ed00SAndrew Rybchenko * 59573ed00SAndrew Rybchenko * Redistribution and use in source and binary forms, with or without 69573ed00SAndrew Rybchenko * modification, are permitted provided that the following conditions are met: 79573ed00SAndrew Rybchenko * 89573ed00SAndrew Rybchenko * 1. Redistributions of source code must retain the above copyright notice, 99573ed00SAndrew Rybchenko * this list of conditions and the following disclaimer. 109573ed00SAndrew Rybchenko * 2. Redistributions in binary form must reproduce the above copyright notice, 119573ed00SAndrew Rybchenko * this list of conditions and the following disclaimer in the documentation 129573ed00SAndrew Rybchenko * and/or other materials provided with the distribution. 139573ed00SAndrew Rybchenko * 149573ed00SAndrew Rybchenko * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 159573ed00SAndrew Rybchenko * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 169573ed00SAndrew Rybchenko * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 179573ed00SAndrew Rybchenko * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 189573ed00SAndrew Rybchenko * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 199573ed00SAndrew Rybchenko * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 209573ed00SAndrew Rybchenko * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 219573ed00SAndrew Rybchenko * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 229573ed00SAndrew Rybchenko * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 239573ed00SAndrew Rybchenko * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 249573ed00SAndrew Rybchenko * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 259573ed00SAndrew Rybchenko * 269573ed00SAndrew Rybchenko * The views and conclusions contained in the software and documentation are 279573ed00SAndrew Rybchenko * those of the authors and should not be interpreted as representing official 289573ed00SAndrew Rybchenko * policies, either expressed or implied, of the FreeBSD Project. 299573ed00SAndrew Rybchenko */ 309573ed00SAndrew Rybchenko 319573ed00SAndrew Rybchenko #include <sys/cdefs.h> 329573ed00SAndrew Rybchenko __FBSDID("$FreeBSD$"); 339573ed00SAndrew Rybchenko 349573ed00SAndrew Rybchenko #include "efx.h" 359573ed00SAndrew Rybchenko #include "efx_impl.h" 369573ed00SAndrew Rybchenko 379573ed00SAndrew Rybchenko 38cbc3f94fSAndrew Rybchenko #if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 399573ed00SAndrew Rybchenko 409573ed00SAndrew Rybchenko __checkReturn efx_rc_t 419573ed00SAndrew Rybchenko ef10_mac_poll( 429573ed00SAndrew Rybchenko __in efx_nic_t *enp, 439573ed00SAndrew Rybchenko __out efx_link_mode_t *link_modep) 449573ed00SAndrew Rybchenko { 459573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 469573ed00SAndrew Rybchenko ef10_link_state_t els; 479573ed00SAndrew Rybchenko efx_rc_t rc; 489573ed00SAndrew Rybchenko 499573ed00SAndrew Rybchenko if ((rc = ef10_phy_get_link(enp, &els)) != 0) 509573ed00SAndrew Rybchenko goto fail1; 519573ed00SAndrew Rybchenko 52*cf94ca37SAndrew Rybchenko epp->ep_adv_cap_mask = els.epls.epls_adv_cap_mask; 53*cf94ca37SAndrew Rybchenko epp->ep_fcntl = els.epls.epls_fcntl; 549573ed00SAndrew Rybchenko 55*cf94ca37SAndrew Rybchenko *link_modep = els.epls.epls_link_mode; 569573ed00SAndrew Rybchenko 579573ed00SAndrew Rybchenko return (0); 589573ed00SAndrew Rybchenko 599573ed00SAndrew Rybchenko fail1: 609573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 619573ed00SAndrew Rybchenko 629573ed00SAndrew Rybchenko *link_modep = EFX_LINK_UNKNOWN; 639573ed00SAndrew Rybchenko 649573ed00SAndrew Rybchenko return (rc); 659573ed00SAndrew Rybchenko } 669573ed00SAndrew Rybchenko 679573ed00SAndrew Rybchenko __checkReturn efx_rc_t 689573ed00SAndrew Rybchenko ef10_mac_up( 699573ed00SAndrew Rybchenko __in efx_nic_t *enp, 709573ed00SAndrew Rybchenko __out boolean_t *mac_upp) 719573ed00SAndrew Rybchenko { 729573ed00SAndrew Rybchenko ef10_link_state_t els; 739573ed00SAndrew Rybchenko efx_rc_t rc; 749573ed00SAndrew Rybchenko 759573ed00SAndrew Rybchenko /* 769573ed00SAndrew Rybchenko * Because EF10 doesn't *require* polling, we can't rely on 779573ed00SAndrew Rybchenko * ef10_mac_poll() being executed to populate epp->ep_mac_up. 789573ed00SAndrew Rybchenko */ 799573ed00SAndrew Rybchenko if ((rc = ef10_phy_get_link(enp, &els)) != 0) 809573ed00SAndrew Rybchenko goto fail1; 819573ed00SAndrew Rybchenko 829573ed00SAndrew Rybchenko *mac_upp = els.els_mac_up; 839573ed00SAndrew Rybchenko 849573ed00SAndrew Rybchenko return (0); 859573ed00SAndrew Rybchenko 869573ed00SAndrew Rybchenko fail1: 879573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 889573ed00SAndrew Rybchenko 899573ed00SAndrew Rybchenko return (rc); 909573ed00SAndrew Rybchenko } 919573ed00SAndrew Rybchenko 929573ed00SAndrew Rybchenko /* 939573ed00SAndrew Rybchenko * EF10 adapters use MC_CMD_VADAPTOR_SET_MAC to set the 949573ed00SAndrew Rybchenko * MAC address; the address field in MC_CMD_SET_MAC has no 959573ed00SAndrew Rybchenko * effect. 969573ed00SAndrew Rybchenko * MC_CMD_VADAPTOR_SET_MAC requires mac-spoofing privilege and 979573ed00SAndrew Rybchenko * the port to have no filters or queues active. 989573ed00SAndrew Rybchenko */ 999573ed00SAndrew Rybchenko static __checkReturn efx_rc_t 1009573ed00SAndrew Rybchenko efx_mcdi_vadapter_set_mac( 1019573ed00SAndrew Rybchenko __in efx_nic_t *enp) 1029573ed00SAndrew Rybchenko { 1039573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 1049573ed00SAndrew Rybchenko efx_mcdi_req_t req; 105315bbbaaSAndrew Rybchenko EFX_MCDI_DECLARE_BUF(payload, MC_CMD_VADAPTOR_SET_MAC_IN_LEN, 106315bbbaaSAndrew Rybchenko MC_CMD_VADAPTOR_SET_MAC_OUT_LEN); 1079573ed00SAndrew Rybchenko efx_rc_t rc; 1089573ed00SAndrew Rybchenko 1099573ed00SAndrew Rybchenko req.emr_cmd = MC_CMD_VADAPTOR_SET_MAC; 1109573ed00SAndrew Rybchenko req.emr_in_buf = payload; 1119573ed00SAndrew Rybchenko req.emr_in_length = MC_CMD_VADAPTOR_SET_MAC_IN_LEN; 1129573ed00SAndrew Rybchenko req.emr_out_buf = payload; 1139573ed00SAndrew Rybchenko req.emr_out_length = MC_CMD_VADAPTOR_SET_MAC_OUT_LEN; 1149573ed00SAndrew Rybchenko 1159573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, VADAPTOR_SET_MAC_IN_UPSTREAM_PORT_ID, 1169573ed00SAndrew Rybchenko enp->en_vport_id); 1179573ed00SAndrew Rybchenko EFX_MAC_ADDR_COPY(MCDI_IN2(req, uint8_t, VADAPTOR_SET_MAC_IN_MACADDR), 1189573ed00SAndrew Rybchenko epp->ep_mac_addr); 1199573ed00SAndrew Rybchenko 1209573ed00SAndrew Rybchenko efx_mcdi_execute(enp, &req); 1219573ed00SAndrew Rybchenko 1229573ed00SAndrew Rybchenko if (req.emr_rc != 0) { 1239573ed00SAndrew Rybchenko rc = req.emr_rc; 1249573ed00SAndrew Rybchenko goto fail1; 1259573ed00SAndrew Rybchenko } 1269573ed00SAndrew Rybchenko 1279573ed00SAndrew Rybchenko return (0); 1289573ed00SAndrew Rybchenko 1299573ed00SAndrew Rybchenko fail1: 1309573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 1319573ed00SAndrew Rybchenko 1329573ed00SAndrew Rybchenko return (rc); 1339573ed00SAndrew Rybchenko } 1349573ed00SAndrew Rybchenko 1359573ed00SAndrew Rybchenko __checkReturn efx_rc_t 1369573ed00SAndrew Rybchenko ef10_mac_addr_set( 1379573ed00SAndrew Rybchenko __in efx_nic_t *enp) 1389573ed00SAndrew Rybchenko { 1399573ed00SAndrew Rybchenko efx_rc_t rc; 1409573ed00SAndrew Rybchenko 1419573ed00SAndrew Rybchenko if ((rc = efx_mcdi_vadapter_set_mac(enp)) != 0) { 1429573ed00SAndrew Rybchenko if (rc != ENOTSUP) 1439573ed00SAndrew Rybchenko goto fail1; 1449573ed00SAndrew Rybchenko 1459573ed00SAndrew Rybchenko /* 1469573ed00SAndrew Rybchenko * Fallback for older Huntington firmware without Vadapter 1479573ed00SAndrew Rybchenko * support. 1489573ed00SAndrew Rybchenko */ 1499573ed00SAndrew Rybchenko if ((rc = ef10_mac_reconfigure(enp)) != 0) 1509573ed00SAndrew Rybchenko goto fail2; 1519573ed00SAndrew Rybchenko } 1529573ed00SAndrew Rybchenko 1539573ed00SAndrew Rybchenko return (0); 1549573ed00SAndrew Rybchenko 1559573ed00SAndrew Rybchenko fail2: 1569573ed00SAndrew Rybchenko EFSYS_PROBE(fail2); 1579573ed00SAndrew Rybchenko 1589573ed00SAndrew Rybchenko fail1: 1599573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 1609573ed00SAndrew Rybchenko 1619573ed00SAndrew Rybchenko return (rc); 1629573ed00SAndrew Rybchenko } 1639573ed00SAndrew Rybchenko 1649573ed00SAndrew Rybchenko static __checkReturn efx_rc_t 1659573ed00SAndrew Rybchenko efx_mcdi_mtu_set( 1669573ed00SAndrew Rybchenko __in efx_nic_t *enp, 1679573ed00SAndrew Rybchenko __in uint32_t mtu) 1689573ed00SAndrew Rybchenko { 1699573ed00SAndrew Rybchenko efx_mcdi_req_t req; 170315bbbaaSAndrew Rybchenko EFX_MCDI_DECLARE_BUF(payload, MC_CMD_SET_MAC_EXT_IN_LEN, 171315bbbaaSAndrew Rybchenko MC_CMD_SET_MAC_OUT_LEN); 1729573ed00SAndrew Rybchenko efx_rc_t rc; 1739573ed00SAndrew Rybchenko 1749573ed00SAndrew Rybchenko req.emr_cmd = MC_CMD_SET_MAC; 1759573ed00SAndrew Rybchenko req.emr_in_buf = payload; 1769573ed00SAndrew Rybchenko req.emr_in_length = MC_CMD_SET_MAC_EXT_IN_LEN; 1779573ed00SAndrew Rybchenko req.emr_out_buf = payload; 1789573ed00SAndrew Rybchenko req.emr_out_length = MC_CMD_SET_MAC_OUT_LEN; 1799573ed00SAndrew Rybchenko 1809573ed00SAndrew Rybchenko /* Only configure the MTU in this call to MC_CMD_SET_MAC */ 1819573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_EXT_IN_MTU, mtu); 1829573ed00SAndrew Rybchenko MCDI_IN_POPULATE_DWORD_1(req, SET_MAC_EXT_IN_CONTROL, 1839573ed00SAndrew Rybchenko SET_MAC_EXT_IN_CFG_MTU, 1); 1849573ed00SAndrew Rybchenko 1859573ed00SAndrew Rybchenko efx_mcdi_execute(enp, &req); 1869573ed00SAndrew Rybchenko 1879573ed00SAndrew Rybchenko if (req.emr_rc != 0) { 1889573ed00SAndrew Rybchenko rc = req.emr_rc; 1899573ed00SAndrew Rybchenko goto fail1; 1909573ed00SAndrew Rybchenko } 1919573ed00SAndrew Rybchenko 1929573ed00SAndrew Rybchenko return (0); 1939573ed00SAndrew Rybchenko 1949573ed00SAndrew Rybchenko fail1: 1959573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 1969573ed00SAndrew Rybchenko 1979573ed00SAndrew Rybchenko return (rc); 1989573ed00SAndrew Rybchenko } 1999573ed00SAndrew Rybchenko 200d8484af2SAndrew Rybchenko static __checkReturn efx_rc_t 201d8484af2SAndrew Rybchenko efx_mcdi_mtu_get( 202d8484af2SAndrew Rybchenko __in efx_nic_t *enp, 203d8484af2SAndrew Rybchenko __out size_t *mtu) 204d8484af2SAndrew Rybchenko { 205d8484af2SAndrew Rybchenko efx_mcdi_req_t req; 206315bbbaaSAndrew Rybchenko EFX_MCDI_DECLARE_BUF(payload, MC_CMD_SET_MAC_EXT_IN_LEN, 207315bbbaaSAndrew Rybchenko MC_CMD_SET_MAC_V2_OUT_LEN); 208d8484af2SAndrew Rybchenko efx_rc_t rc; 209d8484af2SAndrew Rybchenko 210d8484af2SAndrew Rybchenko req.emr_cmd = MC_CMD_SET_MAC; 211d8484af2SAndrew Rybchenko req.emr_in_buf = payload; 212d8484af2SAndrew Rybchenko req.emr_in_length = MC_CMD_SET_MAC_EXT_IN_LEN; 213d8484af2SAndrew Rybchenko req.emr_out_buf = payload; 214d8484af2SAndrew Rybchenko req.emr_out_length = MC_CMD_SET_MAC_V2_OUT_LEN; 215d8484af2SAndrew Rybchenko 216d8484af2SAndrew Rybchenko /* 217d8484af2SAndrew Rybchenko * With MC_CMD_SET_MAC_EXT_IN_CONTROL set to 0, this just queries the 218d8484af2SAndrew Rybchenko * MTU. This should always be supported on Medford, but it is not 219d8484af2SAndrew Rybchenko * supported on older Huntington firmware. 220d8484af2SAndrew Rybchenko */ 221d8484af2SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_EXT_IN_CONTROL, 0); 222d8484af2SAndrew Rybchenko 223d8484af2SAndrew Rybchenko efx_mcdi_execute(enp, &req); 224d8484af2SAndrew Rybchenko 225d8484af2SAndrew Rybchenko if (req.emr_rc != 0) { 226d8484af2SAndrew Rybchenko rc = req.emr_rc; 227d8484af2SAndrew Rybchenko goto fail1; 228d8484af2SAndrew Rybchenko } 229d8484af2SAndrew Rybchenko if (req.emr_out_length_used < MC_CMD_SET_MAC_V2_OUT_MTU_OFST + 4) { 230d8484af2SAndrew Rybchenko rc = EMSGSIZE; 231d8484af2SAndrew Rybchenko goto fail2; 232d8484af2SAndrew Rybchenko } 233d8484af2SAndrew Rybchenko 234d8484af2SAndrew Rybchenko *mtu = MCDI_OUT_DWORD(req, SET_MAC_V2_OUT_MTU); 235d8484af2SAndrew Rybchenko 236d8484af2SAndrew Rybchenko return (0); 237d8484af2SAndrew Rybchenko 238d8484af2SAndrew Rybchenko fail2: 239d8484af2SAndrew Rybchenko EFSYS_PROBE(fail2); 240d8484af2SAndrew Rybchenko fail1: 241d8484af2SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 242d8484af2SAndrew Rybchenko 243d8484af2SAndrew Rybchenko return (rc); 244d8484af2SAndrew Rybchenko } 245d8484af2SAndrew Rybchenko 2469573ed00SAndrew Rybchenko __checkReturn efx_rc_t 2479573ed00SAndrew Rybchenko ef10_mac_pdu_set( 2489573ed00SAndrew Rybchenko __in efx_nic_t *enp) 2499573ed00SAndrew Rybchenko { 2509573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 2519573ed00SAndrew Rybchenko efx_nic_cfg_t *encp = &(enp->en_nic_cfg); 2529573ed00SAndrew Rybchenko efx_rc_t rc; 2539573ed00SAndrew Rybchenko 2549573ed00SAndrew Rybchenko if (encp->enc_enhanced_set_mac_supported) { 2559573ed00SAndrew Rybchenko if ((rc = efx_mcdi_mtu_set(enp, epp->ep_mac_pdu)) != 0) 2569573ed00SAndrew Rybchenko goto fail1; 2579573ed00SAndrew Rybchenko } else { 2589573ed00SAndrew Rybchenko /* 2599573ed00SAndrew Rybchenko * Fallback for older Huntington firmware, which always 2609573ed00SAndrew Rybchenko * configure all of the parameters to MC_CMD_SET_MAC. This isn't 2619573ed00SAndrew Rybchenko * suitable for setting the MTU on unpriviliged functions. 2629573ed00SAndrew Rybchenko */ 2639573ed00SAndrew Rybchenko if ((rc = ef10_mac_reconfigure(enp)) != 0) 2649573ed00SAndrew Rybchenko goto fail2; 2659573ed00SAndrew Rybchenko } 2669573ed00SAndrew Rybchenko 2679573ed00SAndrew Rybchenko return (0); 2689573ed00SAndrew Rybchenko 2699573ed00SAndrew Rybchenko fail2: 2709573ed00SAndrew Rybchenko EFSYS_PROBE(fail2); 2719573ed00SAndrew Rybchenko fail1: 2729573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 2739573ed00SAndrew Rybchenko 2749573ed00SAndrew Rybchenko return (rc); 2759573ed00SAndrew Rybchenko } 2769573ed00SAndrew Rybchenko 2779573ed00SAndrew Rybchenko __checkReturn efx_rc_t 278d8484af2SAndrew Rybchenko ef10_mac_pdu_get( 279d8484af2SAndrew Rybchenko __in efx_nic_t *enp, 280d8484af2SAndrew Rybchenko __out size_t *pdu) 281d8484af2SAndrew Rybchenko { 282d8484af2SAndrew Rybchenko efx_rc_t rc; 283d8484af2SAndrew Rybchenko 284d8484af2SAndrew Rybchenko if ((rc = efx_mcdi_mtu_get(enp, pdu)) != 0) 285d8484af2SAndrew Rybchenko goto fail1; 286d8484af2SAndrew Rybchenko 287d8484af2SAndrew Rybchenko return (0); 288d8484af2SAndrew Rybchenko 289d8484af2SAndrew Rybchenko fail1: 290d8484af2SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 291d8484af2SAndrew Rybchenko 292d8484af2SAndrew Rybchenko return (rc); 293d8484af2SAndrew Rybchenko } 294d8484af2SAndrew Rybchenko 295d8484af2SAndrew Rybchenko __checkReturn efx_rc_t 2969573ed00SAndrew Rybchenko ef10_mac_reconfigure( 2979573ed00SAndrew Rybchenko __in efx_nic_t *enp) 2989573ed00SAndrew Rybchenko { 2999573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 3009573ed00SAndrew Rybchenko efx_mcdi_req_t req; 301315bbbaaSAndrew Rybchenko EFX_MCDI_DECLARE_BUF(payload, MC_CMD_SET_MAC_IN_LEN, 302315bbbaaSAndrew Rybchenko MC_CMD_SET_MAC_OUT_LEN); 3039573ed00SAndrew Rybchenko efx_rc_t rc; 3049573ed00SAndrew Rybchenko 3059573ed00SAndrew Rybchenko req.emr_cmd = MC_CMD_SET_MAC; 3069573ed00SAndrew Rybchenko req.emr_in_buf = payload; 3079573ed00SAndrew Rybchenko req.emr_in_length = MC_CMD_SET_MAC_IN_LEN; 3089573ed00SAndrew Rybchenko req.emr_out_buf = payload; 3099573ed00SAndrew Rybchenko req.emr_out_length = MC_CMD_SET_MAC_OUT_LEN; 3109573ed00SAndrew Rybchenko 3119573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_IN_MTU, epp->ep_mac_pdu); 3129573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_IN_DRAIN, epp->ep_mac_drain ? 1 : 0); 3139573ed00SAndrew Rybchenko EFX_MAC_ADDR_COPY(MCDI_IN2(req, uint8_t, SET_MAC_IN_ADDR), 3149573ed00SAndrew Rybchenko epp->ep_mac_addr); 3159573ed00SAndrew Rybchenko 3169573ed00SAndrew Rybchenko /* 3179573ed00SAndrew Rybchenko * Note: The Huntington MAC does not support REJECT_BRDCST. 3189573ed00SAndrew Rybchenko * The REJECT_UNCST flag will also prevent multicast traffic 3199573ed00SAndrew Rybchenko * from reaching the filters. As Huntington filters drop any 3209573ed00SAndrew Rybchenko * traffic that does not match a filter it is ok to leave the 3219573ed00SAndrew Rybchenko * MAC running in promiscuous mode. See bug41141. 3229573ed00SAndrew Rybchenko * 3239573ed00SAndrew Rybchenko * FIXME: Does REJECT_UNCST behave the same way on Medford? 3249573ed00SAndrew Rybchenko */ 3259573ed00SAndrew Rybchenko MCDI_IN_POPULATE_DWORD_2(req, SET_MAC_IN_REJECT, 3269573ed00SAndrew Rybchenko SET_MAC_IN_REJECT_UNCST, 0, 3279573ed00SAndrew Rybchenko SET_MAC_IN_REJECT_BRDCST, 0); 3289573ed00SAndrew Rybchenko 3299573ed00SAndrew Rybchenko /* 3309573ed00SAndrew Rybchenko * Flow control, whether it is auto-negotiated or not, 3319573ed00SAndrew Rybchenko * is set via the PHY advertised capabilities. When set to 3329573ed00SAndrew Rybchenko * automatic the MAC will use the PHY settings to determine 3339573ed00SAndrew Rybchenko * the flow control settings. 3349573ed00SAndrew Rybchenko */ 3359573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_IN_FCNTL, MC_CMD_FCNTL_AUTO); 3369573ed00SAndrew Rybchenko 3379573ed00SAndrew Rybchenko /* Do not include the Ethernet frame checksum in RX packets */ 3389573ed00SAndrew Rybchenko MCDI_IN_POPULATE_DWORD_1(req, SET_MAC_IN_FLAGS, 3399573ed00SAndrew Rybchenko SET_MAC_IN_FLAG_INCLUDE_FCS, 0); 3409573ed00SAndrew Rybchenko 3419573ed00SAndrew Rybchenko efx_mcdi_execute_quiet(enp, &req); 3429573ed00SAndrew Rybchenko 3439573ed00SAndrew Rybchenko if (req.emr_rc != 0) { 3449573ed00SAndrew Rybchenko /* 3459573ed00SAndrew Rybchenko * Unprivileged functions cannot control link state, 3469573ed00SAndrew Rybchenko * but still need to configure filters. 3479573ed00SAndrew Rybchenko */ 3489573ed00SAndrew Rybchenko if (req.emr_rc != EACCES) { 3499573ed00SAndrew Rybchenko rc = req.emr_rc; 3509573ed00SAndrew Rybchenko goto fail1; 3519573ed00SAndrew Rybchenko } 3529573ed00SAndrew Rybchenko } 3539573ed00SAndrew Rybchenko 3549573ed00SAndrew Rybchenko /* 3559573ed00SAndrew Rybchenko * Apply the filters for the MAC configuration. 3569573ed00SAndrew Rybchenko * If the NIC isn't ready to accept filters this may 3579573ed00SAndrew Rybchenko * return success without setting anything. 3589573ed00SAndrew Rybchenko */ 3599573ed00SAndrew Rybchenko rc = efx_filter_reconfigure(enp, epp->ep_mac_addr, 3609573ed00SAndrew Rybchenko epp->ep_all_unicst, epp->ep_mulcst, 3619573ed00SAndrew Rybchenko epp->ep_all_mulcst, epp->ep_brdcst, 3629573ed00SAndrew Rybchenko epp->ep_mulcst_addr_list, 3639573ed00SAndrew Rybchenko epp->ep_mulcst_addr_count); 3649573ed00SAndrew Rybchenko 3659573ed00SAndrew Rybchenko return (0); 3669573ed00SAndrew Rybchenko 3679573ed00SAndrew Rybchenko fail1: 3689573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 3699573ed00SAndrew Rybchenko 3709573ed00SAndrew Rybchenko return (rc); 3719573ed00SAndrew Rybchenko } 3729573ed00SAndrew Rybchenko 3739573ed00SAndrew Rybchenko __checkReturn efx_rc_t 3749573ed00SAndrew Rybchenko ef10_mac_multicast_list_set( 3759573ed00SAndrew Rybchenko __in efx_nic_t *enp) 3769573ed00SAndrew Rybchenko { 3779573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 3789573ed00SAndrew Rybchenko const efx_mac_ops_t *emop = epp->ep_emop; 3799573ed00SAndrew Rybchenko efx_rc_t rc; 3809573ed00SAndrew Rybchenko 3819573ed00SAndrew Rybchenko EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || 382cbc3f94fSAndrew Rybchenko enp->en_family == EFX_FAMILY_MEDFORD || 383cbc3f94fSAndrew Rybchenko enp->en_family == EFX_FAMILY_MEDFORD2); 3849573ed00SAndrew Rybchenko 3859573ed00SAndrew Rybchenko if ((rc = emop->emo_reconfigure(enp)) != 0) 3869573ed00SAndrew Rybchenko goto fail1; 3879573ed00SAndrew Rybchenko 3889573ed00SAndrew Rybchenko return (0); 3899573ed00SAndrew Rybchenko 3909573ed00SAndrew Rybchenko fail1: 3919573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 3929573ed00SAndrew Rybchenko 3939573ed00SAndrew Rybchenko return (rc); 3949573ed00SAndrew Rybchenko } 3959573ed00SAndrew Rybchenko 3969573ed00SAndrew Rybchenko __checkReturn efx_rc_t 3979573ed00SAndrew Rybchenko ef10_mac_filter_default_rxq_set( 3989573ed00SAndrew Rybchenko __in efx_nic_t *enp, 3999573ed00SAndrew Rybchenko __in efx_rxq_t *erp, 4009573ed00SAndrew Rybchenko __in boolean_t using_rss) 4019573ed00SAndrew Rybchenko { 4029573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 4039573ed00SAndrew Rybchenko efx_rxq_t *old_rxq; 4049573ed00SAndrew Rybchenko boolean_t old_using_rss; 4059573ed00SAndrew Rybchenko efx_rc_t rc; 4069573ed00SAndrew Rybchenko 4079573ed00SAndrew Rybchenko ef10_filter_get_default_rxq(enp, &old_rxq, &old_using_rss); 4089573ed00SAndrew Rybchenko 4099573ed00SAndrew Rybchenko ef10_filter_default_rxq_set(enp, erp, using_rss); 4109573ed00SAndrew Rybchenko 4119573ed00SAndrew Rybchenko rc = efx_filter_reconfigure(enp, epp->ep_mac_addr, 4129573ed00SAndrew Rybchenko epp->ep_all_unicst, epp->ep_mulcst, 4139573ed00SAndrew Rybchenko epp->ep_all_mulcst, epp->ep_brdcst, 4149573ed00SAndrew Rybchenko epp->ep_mulcst_addr_list, 4159573ed00SAndrew Rybchenko epp->ep_mulcst_addr_count); 4169573ed00SAndrew Rybchenko 4179573ed00SAndrew Rybchenko if (rc != 0) 4189573ed00SAndrew Rybchenko goto fail1; 4199573ed00SAndrew Rybchenko 4209573ed00SAndrew Rybchenko return (0); 4219573ed00SAndrew Rybchenko 4229573ed00SAndrew Rybchenko fail1: 4239573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 4249573ed00SAndrew Rybchenko 4259573ed00SAndrew Rybchenko ef10_filter_default_rxq_set(enp, old_rxq, old_using_rss); 4269573ed00SAndrew Rybchenko 4279573ed00SAndrew Rybchenko return (rc); 4289573ed00SAndrew Rybchenko } 4299573ed00SAndrew Rybchenko 4309573ed00SAndrew Rybchenko void 4319573ed00SAndrew Rybchenko ef10_mac_filter_default_rxq_clear( 4329573ed00SAndrew Rybchenko __in efx_nic_t *enp) 4339573ed00SAndrew Rybchenko { 4349573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 4359573ed00SAndrew Rybchenko 4369573ed00SAndrew Rybchenko ef10_filter_default_rxq_clear(enp); 4379573ed00SAndrew Rybchenko 438e4ddd4ccSAndrew Rybchenko (void) efx_filter_reconfigure(enp, epp->ep_mac_addr, 4399573ed00SAndrew Rybchenko epp->ep_all_unicst, epp->ep_mulcst, 4409573ed00SAndrew Rybchenko epp->ep_all_mulcst, epp->ep_brdcst, 4419573ed00SAndrew Rybchenko epp->ep_mulcst_addr_list, 4429573ed00SAndrew Rybchenko epp->ep_mulcst_addr_count); 4439573ed00SAndrew Rybchenko } 4449573ed00SAndrew Rybchenko 4459573ed00SAndrew Rybchenko 4469573ed00SAndrew Rybchenko #if EFSYS_OPT_LOOPBACK 4479573ed00SAndrew Rybchenko 4489573ed00SAndrew Rybchenko __checkReturn efx_rc_t 4499573ed00SAndrew Rybchenko ef10_mac_loopback_set( 4509573ed00SAndrew Rybchenko __in efx_nic_t *enp, 4519573ed00SAndrew Rybchenko __in efx_link_mode_t link_mode, 4529573ed00SAndrew Rybchenko __in efx_loopback_type_t loopback_type) 4539573ed00SAndrew Rybchenko { 4549573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 4559573ed00SAndrew Rybchenko const efx_phy_ops_t *epop = epp->ep_epop; 4569573ed00SAndrew Rybchenko efx_loopback_type_t old_loopback_type; 4579573ed00SAndrew Rybchenko efx_link_mode_t old_loopback_link_mode; 4589573ed00SAndrew Rybchenko efx_rc_t rc; 4599573ed00SAndrew Rybchenko 4609573ed00SAndrew Rybchenko /* The PHY object handles this on EF10 */ 4619573ed00SAndrew Rybchenko old_loopback_type = epp->ep_loopback_type; 4629573ed00SAndrew Rybchenko old_loopback_link_mode = epp->ep_loopback_link_mode; 4639573ed00SAndrew Rybchenko epp->ep_loopback_type = loopback_type; 4649573ed00SAndrew Rybchenko epp->ep_loopback_link_mode = link_mode; 4659573ed00SAndrew Rybchenko 4669573ed00SAndrew Rybchenko if ((rc = epop->epo_reconfigure(enp)) != 0) 4679573ed00SAndrew Rybchenko goto fail1; 4689573ed00SAndrew Rybchenko 4699573ed00SAndrew Rybchenko return (0); 4709573ed00SAndrew Rybchenko 4719573ed00SAndrew Rybchenko fail1: 4729573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 4739573ed00SAndrew Rybchenko 4749573ed00SAndrew Rybchenko epp->ep_loopback_type = old_loopback_type; 4759573ed00SAndrew Rybchenko epp->ep_loopback_link_mode = old_loopback_link_mode; 4769573ed00SAndrew Rybchenko 4779573ed00SAndrew Rybchenko return (rc); 4789573ed00SAndrew Rybchenko } 4799573ed00SAndrew Rybchenko 4809573ed00SAndrew Rybchenko #endif /* EFSYS_OPT_LOOPBACK */ 4819573ed00SAndrew Rybchenko 4829573ed00SAndrew Rybchenko #if EFSYS_OPT_MAC_STATS 4839573ed00SAndrew Rybchenko 48458a72cb2SAndrew Rybchenko __checkReturn efx_rc_t 48558a72cb2SAndrew Rybchenko ef10_mac_stats_get_mask( 48658a72cb2SAndrew Rybchenko __in efx_nic_t *enp, 48758a72cb2SAndrew Rybchenko __inout_bcount(mask_size) uint32_t *maskp, 48858a72cb2SAndrew Rybchenko __in size_t mask_size) 48958a72cb2SAndrew Rybchenko { 49058a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_common[] = { 49158a72cb2SAndrew Rybchenko { EFX_MAC_RX_OCTETS, EFX_MAC_RX_GE_15XX_PKTS }, 49258a72cb2SAndrew Rybchenko { EFX_MAC_RX_FCS_ERRORS, EFX_MAC_RX_DROP_EVENTS }, 49358a72cb2SAndrew Rybchenko { EFX_MAC_RX_JABBER_PKTS, EFX_MAC_RX_JABBER_PKTS }, 49458a72cb2SAndrew Rybchenko { EFX_MAC_RX_NODESC_DROP_CNT, EFX_MAC_TX_PAUSE_PKTS }, 49558a72cb2SAndrew Rybchenko }; 49658a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_tx_size_bins[] = { 49758a72cb2SAndrew Rybchenko { EFX_MAC_TX_LE_64_PKTS, EFX_MAC_TX_GE_15XX_PKTS }, 49858a72cb2SAndrew Rybchenko }; 49958a72cb2SAndrew Rybchenko efx_nic_cfg_t *encp = &(enp->en_nic_cfg); 50058a72cb2SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 50158a72cb2SAndrew Rybchenko efx_rc_t rc; 50258a72cb2SAndrew Rybchenko 50358a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 50458a72cb2SAndrew Rybchenko ef10_common, EFX_ARRAY_SIZE(ef10_common))) != 0) 50558a72cb2SAndrew Rybchenko goto fail1; 50658a72cb2SAndrew Rybchenko 50758a72cb2SAndrew Rybchenko if (epp->ep_phy_cap_mask & (1 << MC_CMD_PHY_CAP_40000FDX_LBN)) { 50858a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_40g_extra[] = { 50958a72cb2SAndrew Rybchenko { EFX_MAC_RX_ALIGN_ERRORS, EFX_MAC_RX_ALIGN_ERRORS }, 51058a72cb2SAndrew Rybchenko }; 51158a72cb2SAndrew Rybchenko 51258a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 51358a72cb2SAndrew Rybchenko ef10_40g_extra, EFX_ARRAY_SIZE(ef10_40g_extra))) != 0) 51458a72cb2SAndrew Rybchenko goto fail2; 51558a72cb2SAndrew Rybchenko 51658a72cb2SAndrew Rybchenko if (encp->enc_mac_stats_40g_tx_size_bins) { 51758a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, 51858a72cb2SAndrew Rybchenko mask_size, ef10_tx_size_bins, 51958a72cb2SAndrew Rybchenko EFX_ARRAY_SIZE(ef10_tx_size_bins))) != 0) 52058a72cb2SAndrew Rybchenko goto fail3; 52158a72cb2SAndrew Rybchenko } 52258a72cb2SAndrew Rybchenko } else { 52358a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 52458a72cb2SAndrew Rybchenko ef10_tx_size_bins, EFX_ARRAY_SIZE(ef10_tx_size_bins))) != 0) 52558a72cb2SAndrew Rybchenko goto fail4; 52658a72cb2SAndrew Rybchenko } 52758a72cb2SAndrew Rybchenko 52858a72cb2SAndrew Rybchenko if (encp->enc_pm_and_rxdp_counters) { 52958a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_pm_and_rxdp[] = { 53058a72cb2SAndrew Rybchenko { EFX_MAC_PM_TRUNC_BB_OVERFLOW, EFX_MAC_RXDP_HLB_WAIT }, 53158a72cb2SAndrew Rybchenko }; 53258a72cb2SAndrew Rybchenko 53358a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 53458a72cb2SAndrew Rybchenko ef10_pm_and_rxdp, EFX_ARRAY_SIZE(ef10_pm_and_rxdp))) != 0) 53558a72cb2SAndrew Rybchenko goto fail5; 53658a72cb2SAndrew Rybchenko } 53758a72cb2SAndrew Rybchenko 53858a72cb2SAndrew Rybchenko if (encp->enc_datapath_cap_evb) { 53958a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_vadaptor[] = { 54058a72cb2SAndrew Rybchenko { EFX_MAC_VADAPTER_RX_UNICAST_PACKETS, 54158a72cb2SAndrew Rybchenko EFX_MAC_VADAPTER_TX_OVERFLOW }, 54258a72cb2SAndrew Rybchenko }; 54358a72cb2SAndrew Rybchenko 54458a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 54558a72cb2SAndrew Rybchenko ef10_vadaptor, EFX_ARRAY_SIZE(ef10_vadaptor))) != 0) 54658a72cb2SAndrew Rybchenko goto fail6; 54758a72cb2SAndrew Rybchenko } 54858a72cb2SAndrew Rybchenko 549747819d2SAndrew Rybchenko if (encp->enc_fec_counters) { 550747819d2SAndrew Rybchenko const struct efx_mac_stats_range ef10_fec[] = { 551747819d2SAndrew Rybchenko { EFX_MAC_FEC_UNCORRECTED_ERRORS, 552747819d2SAndrew Rybchenko EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE3 }, 553747819d2SAndrew Rybchenko }; 554747819d2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 555747819d2SAndrew Rybchenko ef10_fec, EFX_ARRAY_SIZE(ef10_fec))) != 0) 556747819d2SAndrew Rybchenko goto fail7; 557747819d2SAndrew Rybchenko } 558747819d2SAndrew Rybchenko 559ef8967c7SAndrew Rybchenko if (encp->enc_mac_stats_nstats >= MC_CMD_MAC_NSTATS_V4) { 560ef8967c7SAndrew Rybchenko const struct efx_mac_stats_range ef10_rxdp_sdt[] = { 561ef8967c7SAndrew Rybchenko { EFX_MAC_RXDP_SCATTER_DISABLED_TRUNC, 562ef8967c7SAndrew Rybchenko EFX_MAC_RXDP_SCATTER_DISABLED_TRUNC }, 563ef8967c7SAndrew Rybchenko }; 564ef8967c7SAndrew Rybchenko 565ef8967c7SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 566ef8967c7SAndrew Rybchenko ef10_rxdp_sdt, EFX_ARRAY_SIZE(ef10_rxdp_sdt))) != 0) 567ef8967c7SAndrew Rybchenko goto fail8; 568ef8967c7SAndrew Rybchenko } 569ef8967c7SAndrew Rybchenko 570aea9d093SAndrew Rybchenko if (encp->enc_hlb_counters) { 571aea9d093SAndrew Rybchenko const struct efx_mac_stats_range ef10_hlb[] = { 572aea9d093SAndrew Rybchenko { EFX_MAC_RXDP_HLB_IDLE, EFX_MAC_RXDP_HLB_TIMEOUT }, 573aea9d093SAndrew Rybchenko }; 574aea9d093SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 575aea9d093SAndrew Rybchenko ef10_hlb, EFX_ARRAY_SIZE(ef10_hlb))) != 0) 576aea9d093SAndrew Rybchenko goto fail9; 577aea9d093SAndrew Rybchenko } 578aea9d093SAndrew Rybchenko 57958a72cb2SAndrew Rybchenko return (0); 58058a72cb2SAndrew Rybchenko 581aea9d093SAndrew Rybchenko fail9: 582aea9d093SAndrew Rybchenko EFSYS_PROBE(fail9); 583ef8967c7SAndrew Rybchenko fail8: 584ef8967c7SAndrew Rybchenko EFSYS_PROBE(fail8); 585747819d2SAndrew Rybchenko fail7: 586747819d2SAndrew Rybchenko EFSYS_PROBE(fail7); 58758a72cb2SAndrew Rybchenko fail6: 58858a72cb2SAndrew Rybchenko EFSYS_PROBE(fail6); 58958a72cb2SAndrew Rybchenko fail5: 59058a72cb2SAndrew Rybchenko EFSYS_PROBE(fail5); 59158a72cb2SAndrew Rybchenko fail4: 59258a72cb2SAndrew Rybchenko EFSYS_PROBE(fail4); 59358a72cb2SAndrew Rybchenko fail3: 59458a72cb2SAndrew Rybchenko EFSYS_PROBE(fail3); 59558a72cb2SAndrew Rybchenko fail2: 59658a72cb2SAndrew Rybchenko EFSYS_PROBE(fail2); 59758a72cb2SAndrew Rybchenko fail1: 59858a72cb2SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 59958a72cb2SAndrew Rybchenko 60058a72cb2SAndrew Rybchenko return (rc); 60158a72cb2SAndrew Rybchenko } 60258a72cb2SAndrew Rybchenko 6039573ed00SAndrew Rybchenko #define EF10_MAC_STAT_READ(_esmp, _field, _eqp) \ 6049573ed00SAndrew Rybchenko EFSYS_MEM_READQ((_esmp), (_field) * sizeof (efx_qword_t), _eqp) 6059573ed00SAndrew Rybchenko 6069573ed00SAndrew Rybchenko 6079573ed00SAndrew Rybchenko __checkReturn efx_rc_t 6089573ed00SAndrew Rybchenko ef10_mac_stats_update( 6099573ed00SAndrew Rybchenko __in efx_nic_t *enp, 6109573ed00SAndrew Rybchenko __in efsys_mem_t *esmp, 6119573ed00SAndrew Rybchenko __inout_ecount(EFX_MAC_NSTATS) efsys_stat_t *stat, 6129573ed00SAndrew Rybchenko __inout_opt uint32_t *generationp) 6139573ed00SAndrew Rybchenko { 614fdfd8bfeSAndrew Rybchenko const efx_nic_cfg_t *encp = &enp->en_nic_cfg; 6159573ed00SAndrew Rybchenko efx_qword_t generation_start; 6169573ed00SAndrew Rybchenko efx_qword_t generation_end; 617fdfd8bfeSAndrew Rybchenko efx_qword_t value; 618fdfd8bfeSAndrew Rybchenko efx_rc_t rc; 6199573ed00SAndrew Rybchenko 620fdfd8bfeSAndrew Rybchenko /* 621fdfd8bfeSAndrew Rybchenko * The MAC_STATS contain start and end generation counters used to 622fdfd8bfeSAndrew Rybchenko * detect when the DMA buffer has been updated during stats decode. 623fdfd8bfeSAndrew Rybchenko * All stats counters are 64bit unsigned values. 624fdfd8bfeSAndrew Rybchenko * 625fdfd8bfeSAndrew Rybchenko * Siena-compatible MAC stats contain MC_CMD_MAC_NSTATS 64bit counters. 626fdfd8bfeSAndrew Rybchenko * The generation end counter is at index MC_CMD_MAC_GENERATION_END 627fdfd8bfeSAndrew Rybchenko * (same as MC_CMD_MAC_NSTATS-1). 628fdfd8bfeSAndrew Rybchenko * 629fdfd8bfeSAndrew Rybchenko * Medford2 and later use a larger DMA buffer: MAC_STATS_NUM_STATS from 630fdfd8bfeSAndrew Rybchenko * MC_CMD_GET_CAPABILITIES_V4_OUT reports the number of 64bit counters. 631fdfd8bfeSAndrew Rybchenko * 632fdfd8bfeSAndrew Rybchenko * Firmware writes the generation end counter as the last counter in the 633fdfd8bfeSAndrew Rybchenko * DMA buffer. Do not use MC_CMD_MAC_GENERATION_END, as that is only 634fdfd8bfeSAndrew Rybchenko * correct for legacy Siena-compatible MAC stats. 635fdfd8bfeSAndrew Rybchenko */ 636fdfd8bfeSAndrew Rybchenko 637fdfd8bfeSAndrew Rybchenko if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS) { 638fdfd8bfeSAndrew Rybchenko /* MAC stats count too small for legacy MAC stats */ 639fdfd8bfeSAndrew Rybchenko rc = ENOSPC; 640fdfd8bfeSAndrew Rybchenko goto fail1; 641fdfd8bfeSAndrew Rybchenko } 642fdfd8bfeSAndrew Rybchenko if (EFSYS_MEM_SIZE(esmp) < 643fdfd8bfeSAndrew Rybchenko (encp->enc_mac_stats_nstats * sizeof (efx_qword_t))) { 644fdfd8bfeSAndrew Rybchenko /* DMA buffer too small */ 645fdfd8bfeSAndrew Rybchenko rc = ENOSPC; 646fdfd8bfeSAndrew Rybchenko goto fail2; 647fdfd8bfeSAndrew Rybchenko } 6489573ed00SAndrew Rybchenko 6499573ed00SAndrew Rybchenko /* Read END first so we don't race with the MC */ 650fdfd8bfeSAndrew Rybchenko EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp)); 651fdfd8bfeSAndrew Rybchenko EF10_MAC_STAT_READ(esmp, (encp->enc_mac_stats_nstats - 1), 6529573ed00SAndrew Rybchenko &generation_end); 6539573ed00SAndrew Rybchenko EFSYS_MEM_READ_BARRIER(); 6549573ed00SAndrew Rybchenko 6559573ed00SAndrew Rybchenko /* TX */ 6569573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_PKTS, &value); 6579573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_PKTS]), &value); 6589573ed00SAndrew Rybchenko 6599573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_CONTROL_PKTS, &value); 6609573ed00SAndrew Rybchenko EFSYS_STAT_SUBR_QWORD(&(stat[EFX_MAC_TX_PKTS]), &value); 6619573ed00SAndrew Rybchenko 6629573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_PAUSE_PKTS, &value); 6639573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_PAUSE_PKTS]), &value); 6649573ed00SAndrew Rybchenko 6659573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_UNICAST_PKTS, &value); 6669573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_UNICST_PKTS]), &value); 6679573ed00SAndrew Rybchenko 6689573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_MULTICAST_PKTS, &value); 6699573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_MULTICST_PKTS]), &value); 6709573ed00SAndrew Rybchenko 6719573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_BROADCAST_PKTS, &value); 6729573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_BRDCST_PKTS]), &value); 6739573ed00SAndrew Rybchenko 6749573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_BYTES, &value); 6759573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_OCTETS]), &value); 6769573ed00SAndrew Rybchenko 6779573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_LT64_PKTS, &value); 6789573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_LE_64_PKTS]), &value); 6799573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_64_PKTS, &value); 680fe094a7cSAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_TX_LE_64_PKTS]), &value); 6819573ed00SAndrew Rybchenko 6829573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_65_TO_127_PKTS, &value); 6839573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_65_TO_127_PKTS]), &value); 6849573ed00SAndrew Rybchenko 6859573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_128_TO_255_PKTS, &value); 6869573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_128_TO_255_PKTS]), &value); 6879573ed00SAndrew Rybchenko 6889573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_256_TO_511_PKTS, &value); 6899573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_256_TO_511_PKTS]), &value); 6909573ed00SAndrew Rybchenko 6919573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_512_TO_1023_PKTS, &value); 6929573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_512_TO_1023_PKTS]), &value); 6939573ed00SAndrew Rybchenko 6949573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_1024_TO_15XX_PKTS, &value); 6959573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_1024_TO_15XX_PKTS]), &value); 6969573ed00SAndrew Rybchenko 6979573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_15XX_TO_JUMBO_PKTS, &value); 6989573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_GE_15XX_PKTS]), &value); 6999573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_GTJUMBO_PKTS, &value); 7009573ed00SAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_TX_GE_15XX_PKTS]), &value); 7019573ed00SAndrew Rybchenko 7029573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_BAD_FCS_PKTS, &value); 7039573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_ERRORS]), &value); 7049573ed00SAndrew Rybchenko 7059573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_SINGLE_COLLISION_PKTS, &value); 7069573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_SGL_COL_PKTS]), &value); 7079573ed00SAndrew Rybchenko 7089573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_MULTIPLE_COLLISION_PKTS, 7099573ed00SAndrew Rybchenko &value); 7109573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_MULT_COL_PKTS]), &value); 7119573ed00SAndrew Rybchenko 7129573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_EXCESSIVE_COLLISION_PKTS, 7139573ed00SAndrew Rybchenko &value); 7149573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_EX_COL_PKTS]), &value); 7159573ed00SAndrew Rybchenko 7169573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_LATE_COLLISION_PKTS, &value); 7179573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_LATE_COL_PKTS]), &value); 7189573ed00SAndrew Rybchenko 7199573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_DEFERRED_PKTS, &value); 7209573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_DEF_PKTS]), &value); 7219573ed00SAndrew Rybchenko 7229573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_EXCESSIVE_DEFERRED_PKTS, 7239573ed00SAndrew Rybchenko &value); 7249573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_EX_DEF_PKTS]), &value); 7259573ed00SAndrew Rybchenko 7269573ed00SAndrew Rybchenko /* RX */ 7279573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_BYTES, &value); 7289573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_OCTETS]), &value); 7299573ed00SAndrew Rybchenko 7309573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_PKTS, &value); 7319573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_PKTS]), &value); 7329573ed00SAndrew Rybchenko 7339573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_UNICAST_PKTS, &value); 7349573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_UNICST_PKTS]), &value); 7359573ed00SAndrew Rybchenko 7369573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_MULTICAST_PKTS, &value); 7379573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_MULTICST_PKTS]), &value); 7389573ed00SAndrew Rybchenko 7399573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_BROADCAST_PKTS, &value); 7409573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_BRDCST_PKTS]), &value); 7419573ed00SAndrew Rybchenko 7429573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_PAUSE_PKTS, &value); 7439573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_PAUSE_PKTS]), &value); 7449573ed00SAndrew Rybchenko 7459573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_UNDERSIZE_PKTS, &value); 7469573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_LE_64_PKTS]), &value); 7479573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_64_PKTS, &value); 7489573ed00SAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_RX_LE_64_PKTS]), &value); 7499573ed00SAndrew Rybchenko 7509573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_65_TO_127_PKTS, &value); 7519573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_65_TO_127_PKTS]), &value); 7529573ed00SAndrew Rybchenko 7539573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_128_TO_255_PKTS, &value); 7549573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_128_TO_255_PKTS]), &value); 7559573ed00SAndrew Rybchenko 7569573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_256_TO_511_PKTS, &value); 7579573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_256_TO_511_PKTS]), &value); 7589573ed00SAndrew Rybchenko 7599573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_512_TO_1023_PKTS, &value); 7609573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_512_TO_1023_PKTS]), &value); 7619573ed00SAndrew Rybchenko 7629573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_1024_TO_15XX_PKTS, &value); 7639573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_1024_TO_15XX_PKTS]), &value); 7649573ed00SAndrew Rybchenko 7659573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_15XX_TO_JUMBO_PKTS, &value); 7669573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_GE_15XX_PKTS]), &value); 7679573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_GTJUMBO_PKTS, &value); 7689573ed00SAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_RX_GE_15XX_PKTS]), &value); 7699573ed00SAndrew Rybchenko 7709573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_BAD_FCS_PKTS, &value); 7719573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_FCS_ERRORS]), &value); 7729573ed00SAndrew Rybchenko 7739573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_OVERFLOW_PKTS, &value); 7749573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_DROP_EVENTS]), &value); 7759573ed00SAndrew Rybchenko 7769573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_FALSE_CARRIER_PKTS, &value); 7779573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_FALSE_CARRIER_ERRORS]), &value); 7789573ed00SAndrew Rybchenko 7799573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_SYMBOL_ERROR_PKTS, &value); 7809573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_SYMBOL_ERRORS]), &value); 7819573ed00SAndrew Rybchenko 7829573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_ALIGN_ERROR_PKTS, &value); 7839573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_ALIGN_ERRORS]), &value); 7849573ed00SAndrew Rybchenko 7859573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_INTERNAL_ERROR_PKTS, &value); 7869573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_INTERNAL_ERRORS]), &value); 7879573ed00SAndrew Rybchenko 7889573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_JABBER_PKTS, &value); 7899573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_JABBER_PKTS]), &value); 7909573ed00SAndrew Rybchenko 7919573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES01_CHAR_ERR, &value); 7929573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE0_CHAR_ERR]), 7939573ed00SAndrew Rybchenko &(value.eq_dword[0])); 7949573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE1_CHAR_ERR]), 7959573ed00SAndrew Rybchenko &(value.eq_dword[1])); 7969573ed00SAndrew Rybchenko 7979573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES23_CHAR_ERR, &value); 7989573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE2_CHAR_ERR]), 7999573ed00SAndrew Rybchenko &(value.eq_dword[0])); 8009573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE3_CHAR_ERR]), 8019573ed00SAndrew Rybchenko &(value.eq_dword[1])); 8029573ed00SAndrew Rybchenko 8039573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES01_DISP_ERR, &value); 8049573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE0_DISP_ERR]), 8059573ed00SAndrew Rybchenko &(value.eq_dword[0])); 8069573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE1_DISP_ERR]), 8079573ed00SAndrew Rybchenko &(value.eq_dword[1])); 8089573ed00SAndrew Rybchenko 8099573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES23_DISP_ERR, &value); 8109573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE2_DISP_ERR]), 8119573ed00SAndrew Rybchenko &(value.eq_dword[0])); 8129573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE3_DISP_ERR]), 8139573ed00SAndrew Rybchenko &(value.eq_dword[1])); 8149573ed00SAndrew Rybchenko 8159573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_MATCH_FAULT, &value); 8169573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_MATCH_FAULT]), &value); 8179573ed00SAndrew Rybchenko 8189573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_NODESC_DROPS, &value); 8199573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_NODESC_DROP_CNT]), &value); 8209573ed00SAndrew Rybchenko 8219573ed00SAndrew Rybchenko /* Packet memory (EF10 only) */ 8229573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_TRUNC_BB_OVERFLOW, &value); 8239573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_TRUNC_BB_OVERFLOW]), &value); 8249573ed00SAndrew Rybchenko 8259573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_BB_OVERFLOW, &value); 8269573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_BB_OVERFLOW]), &value); 8279573ed00SAndrew Rybchenko 8289573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_TRUNC_VFIFO_FULL, &value); 8299573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_TRUNC_VFIFO_FULL]), &value); 8309573ed00SAndrew Rybchenko 8319573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_VFIFO_FULL, &value); 8329573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_VFIFO_FULL]), &value); 8339573ed00SAndrew Rybchenko 8349573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_TRUNC_QBB, &value); 8359573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_TRUNC_QBB]), &value); 8369573ed00SAndrew Rybchenko 8379573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_QBB, &value); 8389573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_QBB]), &value); 8399573ed00SAndrew Rybchenko 8409573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_MAPPING, &value); 8419573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_MAPPING]), &value); 8429573ed00SAndrew Rybchenko 8439573ed00SAndrew Rybchenko /* RX datapath */ 8449573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_Q_DISABLED_PKTS, &value); 8459573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_Q_DISABLED_PKTS]), &value); 8469573ed00SAndrew Rybchenko 8479573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_DI_DROPPED_PKTS, &value); 8489573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_DI_DROPPED_PKTS]), &value); 8499573ed00SAndrew Rybchenko 8509573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_STREAMING_PKTS, &value); 8519573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_STREAMING_PKTS]), &value); 8529573ed00SAndrew Rybchenko 8539573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_HLB_FETCH_CONDITIONS, &value); 8549573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_HLB_FETCH]), &value); 8559573ed00SAndrew Rybchenko 8569573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_HLB_WAIT_CONDITIONS, &value); 8579573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_HLB_WAIT]), &value); 8589573ed00SAndrew Rybchenko 8599573ed00SAndrew Rybchenko 8609573ed00SAndrew Rybchenko /* VADAPTER RX */ 8619573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_UNICAST_PACKETS, 8629573ed00SAndrew Rybchenko &value); 8639573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_UNICAST_PACKETS]), 8649573ed00SAndrew Rybchenko &value); 8659573ed00SAndrew Rybchenko 8669573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_UNICAST_BYTES, 8679573ed00SAndrew Rybchenko &value); 8689573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_UNICAST_BYTES]), 8699573ed00SAndrew Rybchenko &value); 8709573ed00SAndrew Rybchenko 8719573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_MULTICAST_PACKETS, 8729573ed00SAndrew Rybchenko &value); 8739573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_MULTICAST_PACKETS]), 8749573ed00SAndrew Rybchenko &value); 8759573ed00SAndrew Rybchenko 8769573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_MULTICAST_BYTES, 8779573ed00SAndrew Rybchenko &value); 8789573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_MULTICAST_BYTES]), 8799573ed00SAndrew Rybchenko &value); 8809573ed00SAndrew Rybchenko 8819573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BROADCAST_PACKETS, 8829573ed00SAndrew Rybchenko &value); 8839573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BROADCAST_PACKETS]), 8849573ed00SAndrew Rybchenko &value); 8859573ed00SAndrew Rybchenko 8869573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BROADCAST_BYTES, 8879573ed00SAndrew Rybchenko &value); 8889573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BROADCAST_BYTES]), 8899573ed00SAndrew Rybchenko &value); 8909573ed00SAndrew Rybchenko 8919573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BAD_PACKETS, 8929573ed00SAndrew Rybchenko &value); 8939573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BAD_PACKETS]), 8949573ed00SAndrew Rybchenko &value); 8959573ed00SAndrew Rybchenko 8969573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BAD_BYTES, &value); 8979573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BAD_BYTES]), &value); 8989573ed00SAndrew Rybchenko 8999573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_OVERFLOW, &value); 9009573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_OVERFLOW]), &value); 9019573ed00SAndrew Rybchenko 9029573ed00SAndrew Rybchenko /* VADAPTER TX */ 9039573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_UNICAST_PACKETS, 9049573ed00SAndrew Rybchenko &value); 9059573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_UNICAST_PACKETS]), 9069573ed00SAndrew Rybchenko &value); 9079573ed00SAndrew Rybchenko 9089573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_UNICAST_BYTES, 9099573ed00SAndrew Rybchenko &value); 9109573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_UNICAST_BYTES]), 9119573ed00SAndrew Rybchenko &value); 9129573ed00SAndrew Rybchenko 9139573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_MULTICAST_PACKETS, 9149573ed00SAndrew Rybchenko &value); 9159573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_MULTICAST_PACKETS]), 9169573ed00SAndrew Rybchenko &value); 9179573ed00SAndrew Rybchenko 9189573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_MULTICAST_BYTES, 9199573ed00SAndrew Rybchenko &value); 9209573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_MULTICAST_BYTES]), 9219573ed00SAndrew Rybchenko &value); 9229573ed00SAndrew Rybchenko 9239573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BROADCAST_PACKETS, 9249573ed00SAndrew Rybchenko &value); 9259573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BROADCAST_PACKETS]), 9269573ed00SAndrew Rybchenko &value); 9279573ed00SAndrew Rybchenko 9289573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BROADCAST_BYTES, 9299573ed00SAndrew Rybchenko &value); 9309573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BROADCAST_BYTES]), 9319573ed00SAndrew Rybchenko &value); 9329573ed00SAndrew Rybchenko 9339573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BAD_PACKETS, &value); 9349573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BAD_PACKETS]), &value); 9359573ed00SAndrew Rybchenko 9369573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BAD_BYTES, &value); 9379573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BAD_BYTES]), &value); 9389573ed00SAndrew Rybchenko 9399573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_OVERFLOW, &value); 9409573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_OVERFLOW]), &value); 9419573ed00SAndrew Rybchenko 942747819d2SAndrew Rybchenko 943747819d2SAndrew Rybchenko if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS_V2) 944747819d2SAndrew Rybchenko goto done; 945747819d2SAndrew Rybchenko 946747819d2SAndrew Rybchenko /* FEC */ 947747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_UNCORRECTED_ERRORS, &value); 948747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_UNCORRECTED_ERRORS]), &value); 949747819d2SAndrew Rybchenko 950747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_ERRORS, &value); 951747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_ERRORS]), &value); 952747819d2SAndrew Rybchenko 953747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_SYMBOLS_LANE0, 954747819d2SAndrew Rybchenko &value); 955747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE0]), 956747819d2SAndrew Rybchenko &value); 957747819d2SAndrew Rybchenko 958747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_SYMBOLS_LANE1, 959747819d2SAndrew Rybchenko &value); 960747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE1]), 961747819d2SAndrew Rybchenko &value); 962747819d2SAndrew Rybchenko 963747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_SYMBOLS_LANE2, 964747819d2SAndrew Rybchenko &value); 965747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE2]), 966747819d2SAndrew Rybchenko &value); 967747819d2SAndrew Rybchenko 968747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_SYMBOLS_LANE3, 969747819d2SAndrew Rybchenko &value); 970747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE3]), 971747819d2SAndrew Rybchenko &value); 972747819d2SAndrew Rybchenko 97374d36c84SAndrew Rybchenko if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS_V3) 97474d36c84SAndrew Rybchenko goto done; 97574d36c84SAndrew Rybchenko 97674d36c84SAndrew Rybchenko /* CTPIO exceptions */ 97774d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_VI_BUSY_FALLBACK, &value); 97874d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_VI_BUSY_FALLBACK]), &value); 97974d36c84SAndrew Rybchenko 98074d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_LONG_WRITE_SUCCESS, &value); 98174d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_LONG_WRITE_SUCCESS]), &value); 98274d36c84SAndrew Rybchenko 98374d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_MISSING_DBELL_FAIL, &value); 98474d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_MISSING_DBELL_FAIL]), &value); 98574d36c84SAndrew Rybchenko 98674d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_OVERFLOW_FAIL, &value); 98774d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_OVERFLOW_FAIL]), &value); 98874d36c84SAndrew Rybchenko 98974d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_UNDERFLOW_FAIL, &value); 99074d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_UNDERFLOW_FAIL]), &value); 99174d36c84SAndrew Rybchenko 99274d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_TIMEOUT_FAIL, &value); 99374d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_TIMEOUT_FAIL]), &value); 99474d36c84SAndrew Rybchenko 99574d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_NONCONTIG_WR_FAIL, &value); 99674d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_NONCONTIG_WR_FAIL]), &value); 99774d36c84SAndrew Rybchenko 99874d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_FRM_CLOBBER_FAIL, &value); 99974d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_FRM_CLOBBER_FAIL]), &value); 100074d36c84SAndrew Rybchenko 100174d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_INVALID_WR_FAIL, &value); 100274d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_INVALID_WR_FAIL]), &value); 100374d36c84SAndrew Rybchenko 100474d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_VI_CLOBBER_FALLBACK, &value); 100574d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_VI_CLOBBER_FALLBACK]), 100674d36c84SAndrew Rybchenko &value); 100774d36c84SAndrew Rybchenko 100874d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_UNQUALIFIED_FALLBACK, &value); 100974d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_UNQUALIFIED_FALLBACK]), 101074d36c84SAndrew Rybchenko &value); 101174d36c84SAndrew Rybchenko 101274d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_RUNT_FALLBACK, &value); 101374d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_RUNT_FALLBACK]), &value); 101474d36c84SAndrew Rybchenko 101574d36c84SAndrew Rybchenko /* CTPIO per-port stats */ 101674d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_SUCCESS, &value); 101774d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_SUCCESS]), &value); 101874d36c84SAndrew Rybchenko 101974d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_FALLBACK, &value); 102074d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_FALLBACK]), &value); 102174d36c84SAndrew Rybchenko 102274d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_POISON, &value); 102374d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_POISON]), &value); 102474d36c84SAndrew Rybchenko 102574d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_ERASE, &value); 102674d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_ERASE]), &value); 102774d36c84SAndrew Rybchenko 1028ef8967c7SAndrew Rybchenko if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS_V4) 1029ef8967c7SAndrew Rybchenko goto done; 1030ef8967c7SAndrew Rybchenko 1031ef8967c7SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_SCATTER_DISABLED_TRUNC, 1032ef8967c7SAndrew Rybchenko &value); 1033ef8967c7SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_SCATTER_DISABLED_TRUNC]), 1034ef8967c7SAndrew Rybchenko &value); 1035ef8967c7SAndrew Rybchenko 1036aea9d093SAndrew Rybchenko /* Head-of-line blocking */ 1037aea9d093SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_HLB_IDLE, &value); 1038aea9d093SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_HLB_IDLE]), &value); 1039aea9d093SAndrew Rybchenko 1040aea9d093SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_HLB_TIMEOUT, &value); 1041aea9d093SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_HLB_TIMEOUT]), &value); 1042aea9d093SAndrew Rybchenko 1043747819d2SAndrew Rybchenko done: 1044fdfd8bfeSAndrew Rybchenko /* Read START generation counter */ 1045fdfd8bfeSAndrew Rybchenko EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp)); 10469573ed00SAndrew Rybchenko EFSYS_MEM_READ_BARRIER(); 10479573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_GENERATION_START, 10489573ed00SAndrew Rybchenko &generation_start); 10499573ed00SAndrew Rybchenko 10509573ed00SAndrew Rybchenko /* Check that we didn't read the stats in the middle of a DMA */ 10519573ed00SAndrew Rybchenko /* Not a good enough check ? */ 10529573ed00SAndrew Rybchenko if (memcmp(&generation_start, &generation_end, 10539573ed00SAndrew Rybchenko sizeof (generation_start))) 10549573ed00SAndrew Rybchenko return (EAGAIN); 10559573ed00SAndrew Rybchenko 10569573ed00SAndrew Rybchenko if (generationp) 10579573ed00SAndrew Rybchenko *generationp = EFX_QWORD_FIELD(generation_start, EFX_DWORD_0); 10589573ed00SAndrew Rybchenko 10599573ed00SAndrew Rybchenko return (0); 1060fdfd8bfeSAndrew Rybchenko 1061fdfd8bfeSAndrew Rybchenko fail2: 1062fdfd8bfeSAndrew Rybchenko EFSYS_PROBE(fail2); 1063fdfd8bfeSAndrew Rybchenko fail1: 1064fdfd8bfeSAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 1065fdfd8bfeSAndrew Rybchenko 1066fdfd8bfeSAndrew Rybchenko return (rc); 10679573ed00SAndrew Rybchenko } 10689573ed00SAndrew Rybchenko 10699573ed00SAndrew Rybchenko #endif /* EFSYS_OPT_MAC_STATS */ 10709573ed00SAndrew Rybchenko 1071cbc3f94fSAndrew Rybchenko #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */ 1072