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 529573ed00SAndrew Rybchenko epp->ep_adv_cap_mask = els.els_adv_cap_mask; 539573ed00SAndrew Rybchenko epp->ep_fcntl = els.els_fcntl; 549573ed00SAndrew Rybchenko 559573ed00SAndrew Rybchenko *link_modep = els.els_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; 1059573ed00SAndrew Rybchenko uint8_t payload[MAX(MC_CMD_VADAPTOR_SET_MAC_IN_LEN, 1069573ed00SAndrew Rybchenko MC_CMD_VADAPTOR_SET_MAC_OUT_LEN)]; 1079573ed00SAndrew Rybchenko efx_rc_t rc; 1089573ed00SAndrew Rybchenko 1099573ed00SAndrew Rybchenko (void) memset(payload, 0, sizeof (payload)); 1109573ed00SAndrew Rybchenko req.emr_cmd = MC_CMD_VADAPTOR_SET_MAC; 1119573ed00SAndrew Rybchenko req.emr_in_buf = payload; 1129573ed00SAndrew Rybchenko req.emr_in_length = MC_CMD_VADAPTOR_SET_MAC_IN_LEN; 1139573ed00SAndrew Rybchenko req.emr_out_buf = payload; 1149573ed00SAndrew Rybchenko req.emr_out_length = MC_CMD_VADAPTOR_SET_MAC_OUT_LEN; 1159573ed00SAndrew Rybchenko 1169573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, VADAPTOR_SET_MAC_IN_UPSTREAM_PORT_ID, 1179573ed00SAndrew Rybchenko enp->en_vport_id); 1189573ed00SAndrew Rybchenko EFX_MAC_ADDR_COPY(MCDI_IN2(req, uint8_t, VADAPTOR_SET_MAC_IN_MACADDR), 1199573ed00SAndrew Rybchenko epp->ep_mac_addr); 1209573ed00SAndrew Rybchenko 1219573ed00SAndrew Rybchenko efx_mcdi_execute(enp, &req); 1229573ed00SAndrew Rybchenko 1239573ed00SAndrew Rybchenko if (req.emr_rc != 0) { 1249573ed00SAndrew Rybchenko rc = req.emr_rc; 1259573ed00SAndrew Rybchenko goto fail1; 1269573ed00SAndrew Rybchenko } 1279573ed00SAndrew Rybchenko 1289573ed00SAndrew Rybchenko return (0); 1299573ed00SAndrew Rybchenko 1309573ed00SAndrew Rybchenko fail1: 1319573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 1329573ed00SAndrew Rybchenko 1339573ed00SAndrew Rybchenko return (rc); 1349573ed00SAndrew Rybchenko } 1359573ed00SAndrew Rybchenko 1369573ed00SAndrew Rybchenko __checkReturn efx_rc_t 1379573ed00SAndrew Rybchenko ef10_mac_addr_set( 1389573ed00SAndrew Rybchenko __in efx_nic_t *enp) 1399573ed00SAndrew Rybchenko { 1409573ed00SAndrew Rybchenko efx_rc_t rc; 1419573ed00SAndrew Rybchenko 1429573ed00SAndrew Rybchenko if ((rc = efx_mcdi_vadapter_set_mac(enp)) != 0) { 1439573ed00SAndrew Rybchenko if (rc != ENOTSUP) 1449573ed00SAndrew Rybchenko goto fail1; 1459573ed00SAndrew Rybchenko 1469573ed00SAndrew Rybchenko /* 1479573ed00SAndrew Rybchenko * Fallback for older Huntington firmware without Vadapter 1489573ed00SAndrew Rybchenko * support. 1499573ed00SAndrew Rybchenko */ 1509573ed00SAndrew Rybchenko if ((rc = ef10_mac_reconfigure(enp)) != 0) 1519573ed00SAndrew Rybchenko goto fail2; 1529573ed00SAndrew Rybchenko } 1539573ed00SAndrew Rybchenko 1549573ed00SAndrew Rybchenko return (0); 1559573ed00SAndrew Rybchenko 1569573ed00SAndrew Rybchenko fail2: 1579573ed00SAndrew Rybchenko EFSYS_PROBE(fail2); 1589573ed00SAndrew Rybchenko 1599573ed00SAndrew Rybchenko fail1: 1609573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 1619573ed00SAndrew Rybchenko 1629573ed00SAndrew Rybchenko return (rc); 1639573ed00SAndrew Rybchenko } 1649573ed00SAndrew Rybchenko 1659573ed00SAndrew Rybchenko static __checkReturn efx_rc_t 1669573ed00SAndrew Rybchenko efx_mcdi_mtu_set( 1679573ed00SAndrew Rybchenko __in efx_nic_t *enp, 1689573ed00SAndrew Rybchenko __in uint32_t mtu) 1699573ed00SAndrew Rybchenko { 1709573ed00SAndrew Rybchenko efx_mcdi_req_t req; 1719573ed00SAndrew Rybchenko uint8_t payload[MAX(MC_CMD_SET_MAC_EXT_IN_LEN, 1729573ed00SAndrew Rybchenko MC_CMD_SET_MAC_OUT_LEN)]; 1739573ed00SAndrew Rybchenko efx_rc_t rc; 1749573ed00SAndrew Rybchenko 1759573ed00SAndrew Rybchenko (void) memset(payload, 0, sizeof (payload)); 1769573ed00SAndrew Rybchenko req.emr_cmd = MC_CMD_SET_MAC; 1779573ed00SAndrew Rybchenko req.emr_in_buf = payload; 1789573ed00SAndrew Rybchenko req.emr_in_length = MC_CMD_SET_MAC_EXT_IN_LEN; 1799573ed00SAndrew Rybchenko req.emr_out_buf = payload; 1809573ed00SAndrew Rybchenko req.emr_out_length = MC_CMD_SET_MAC_OUT_LEN; 1819573ed00SAndrew Rybchenko 1829573ed00SAndrew Rybchenko /* Only configure the MTU in this call to MC_CMD_SET_MAC */ 1839573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_EXT_IN_MTU, mtu); 1849573ed00SAndrew Rybchenko MCDI_IN_POPULATE_DWORD_1(req, SET_MAC_EXT_IN_CONTROL, 1859573ed00SAndrew Rybchenko SET_MAC_EXT_IN_CFG_MTU, 1); 1869573ed00SAndrew Rybchenko 1879573ed00SAndrew Rybchenko efx_mcdi_execute(enp, &req); 1889573ed00SAndrew Rybchenko 1899573ed00SAndrew Rybchenko if (req.emr_rc != 0) { 1909573ed00SAndrew Rybchenko rc = req.emr_rc; 1919573ed00SAndrew Rybchenko goto fail1; 1929573ed00SAndrew Rybchenko } 1939573ed00SAndrew Rybchenko 1949573ed00SAndrew Rybchenko return (0); 1959573ed00SAndrew Rybchenko 1969573ed00SAndrew Rybchenko fail1: 1979573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 1989573ed00SAndrew Rybchenko 1999573ed00SAndrew Rybchenko return (rc); 2009573ed00SAndrew Rybchenko } 2019573ed00SAndrew Rybchenko 202d8484af2SAndrew Rybchenko static __checkReturn efx_rc_t 203d8484af2SAndrew Rybchenko efx_mcdi_mtu_get( 204d8484af2SAndrew Rybchenko __in efx_nic_t *enp, 205d8484af2SAndrew Rybchenko __out size_t *mtu) 206d8484af2SAndrew Rybchenko { 207d8484af2SAndrew Rybchenko efx_mcdi_req_t req; 208d8484af2SAndrew Rybchenko uint8_t payload[MAX(MC_CMD_SET_MAC_EXT_IN_LEN, 209d8484af2SAndrew Rybchenko MC_CMD_SET_MAC_V2_OUT_LEN)]; 210d8484af2SAndrew Rybchenko efx_rc_t rc; 211d8484af2SAndrew Rybchenko 212d8484af2SAndrew Rybchenko (void) memset(payload, 0, sizeof (payload)); 213d8484af2SAndrew Rybchenko req.emr_cmd = MC_CMD_SET_MAC; 214d8484af2SAndrew Rybchenko req.emr_in_buf = payload; 215d8484af2SAndrew Rybchenko req.emr_in_length = MC_CMD_SET_MAC_EXT_IN_LEN; 216d8484af2SAndrew Rybchenko req.emr_out_buf = payload; 217d8484af2SAndrew Rybchenko req.emr_out_length = MC_CMD_SET_MAC_V2_OUT_LEN; 218d8484af2SAndrew Rybchenko 219d8484af2SAndrew Rybchenko /* 220d8484af2SAndrew Rybchenko * With MC_CMD_SET_MAC_EXT_IN_CONTROL set to 0, this just queries the 221d8484af2SAndrew Rybchenko * MTU. This should always be supported on Medford, but it is not 222d8484af2SAndrew Rybchenko * supported on older Huntington firmware. 223d8484af2SAndrew Rybchenko */ 224d8484af2SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_EXT_IN_CONTROL, 0); 225d8484af2SAndrew Rybchenko 226d8484af2SAndrew Rybchenko efx_mcdi_execute(enp, &req); 227d8484af2SAndrew Rybchenko 228d8484af2SAndrew Rybchenko if (req.emr_rc != 0) { 229d8484af2SAndrew Rybchenko rc = req.emr_rc; 230d8484af2SAndrew Rybchenko goto fail1; 231d8484af2SAndrew Rybchenko } 232d8484af2SAndrew Rybchenko if (req.emr_out_length_used < MC_CMD_SET_MAC_V2_OUT_MTU_OFST + 4) { 233d8484af2SAndrew Rybchenko rc = EMSGSIZE; 234d8484af2SAndrew Rybchenko goto fail2; 235d8484af2SAndrew Rybchenko } 236d8484af2SAndrew Rybchenko 237d8484af2SAndrew Rybchenko *mtu = MCDI_OUT_DWORD(req, SET_MAC_V2_OUT_MTU); 238d8484af2SAndrew Rybchenko 239d8484af2SAndrew Rybchenko return (0); 240d8484af2SAndrew Rybchenko 241d8484af2SAndrew Rybchenko fail2: 242d8484af2SAndrew Rybchenko EFSYS_PROBE(fail2); 243d8484af2SAndrew Rybchenko fail1: 244d8484af2SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 245d8484af2SAndrew Rybchenko 246d8484af2SAndrew Rybchenko return (rc); 247d8484af2SAndrew Rybchenko } 248d8484af2SAndrew Rybchenko 2499573ed00SAndrew Rybchenko __checkReturn efx_rc_t 2509573ed00SAndrew Rybchenko ef10_mac_pdu_set( 2519573ed00SAndrew Rybchenko __in efx_nic_t *enp) 2529573ed00SAndrew Rybchenko { 2539573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 2549573ed00SAndrew Rybchenko efx_nic_cfg_t *encp = &(enp->en_nic_cfg); 2559573ed00SAndrew Rybchenko efx_rc_t rc; 2569573ed00SAndrew Rybchenko 2579573ed00SAndrew Rybchenko if (encp->enc_enhanced_set_mac_supported) { 2589573ed00SAndrew Rybchenko if ((rc = efx_mcdi_mtu_set(enp, epp->ep_mac_pdu)) != 0) 2599573ed00SAndrew Rybchenko goto fail1; 2609573ed00SAndrew Rybchenko } else { 2619573ed00SAndrew Rybchenko /* 2629573ed00SAndrew Rybchenko * Fallback for older Huntington firmware, which always 2639573ed00SAndrew Rybchenko * configure all of the parameters to MC_CMD_SET_MAC. This isn't 2649573ed00SAndrew Rybchenko * suitable for setting the MTU on unpriviliged functions. 2659573ed00SAndrew Rybchenko */ 2669573ed00SAndrew Rybchenko if ((rc = ef10_mac_reconfigure(enp)) != 0) 2679573ed00SAndrew Rybchenko goto fail2; 2689573ed00SAndrew Rybchenko } 2699573ed00SAndrew Rybchenko 2709573ed00SAndrew Rybchenko return (0); 2719573ed00SAndrew Rybchenko 2729573ed00SAndrew Rybchenko fail2: 2739573ed00SAndrew Rybchenko EFSYS_PROBE(fail2); 2749573ed00SAndrew Rybchenko fail1: 2759573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 2769573ed00SAndrew Rybchenko 2779573ed00SAndrew Rybchenko return (rc); 2789573ed00SAndrew Rybchenko } 2799573ed00SAndrew Rybchenko 2809573ed00SAndrew Rybchenko __checkReturn efx_rc_t 281d8484af2SAndrew Rybchenko ef10_mac_pdu_get( 282d8484af2SAndrew Rybchenko __in efx_nic_t *enp, 283d8484af2SAndrew Rybchenko __out size_t *pdu) 284d8484af2SAndrew Rybchenko { 285d8484af2SAndrew Rybchenko efx_rc_t rc; 286d8484af2SAndrew Rybchenko 287d8484af2SAndrew Rybchenko if ((rc = efx_mcdi_mtu_get(enp, pdu)) != 0) 288d8484af2SAndrew Rybchenko goto fail1; 289d8484af2SAndrew Rybchenko 290d8484af2SAndrew Rybchenko return (0); 291d8484af2SAndrew Rybchenko 292d8484af2SAndrew Rybchenko fail1: 293d8484af2SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 294d8484af2SAndrew Rybchenko 295d8484af2SAndrew Rybchenko return (rc); 296d8484af2SAndrew Rybchenko } 297d8484af2SAndrew Rybchenko 298d8484af2SAndrew Rybchenko __checkReturn efx_rc_t 2999573ed00SAndrew Rybchenko ef10_mac_reconfigure( 3009573ed00SAndrew Rybchenko __in efx_nic_t *enp) 3019573ed00SAndrew Rybchenko { 3029573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 3039573ed00SAndrew Rybchenko efx_mcdi_req_t req; 3049573ed00SAndrew Rybchenko uint8_t payload[MAX(MC_CMD_SET_MAC_IN_LEN, 3059573ed00SAndrew Rybchenko MC_CMD_SET_MAC_OUT_LEN)]; 3069573ed00SAndrew Rybchenko efx_rc_t rc; 3079573ed00SAndrew Rybchenko 3089573ed00SAndrew Rybchenko (void) memset(payload, 0, sizeof (payload)); 3099573ed00SAndrew Rybchenko req.emr_cmd = MC_CMD_SET_MAC; 3109573ed00SAndrew Rybchenko req.emr_in_buf = payload; 3119573ed00SAndrew Rybchenko req.emr_in_length = MC_CMD_SET_MAC_IN_LEN; 3129573ed00SAndrew Rybchenko req.emr_out_buf = payload; 3139573ed00SAndrew Rybchenko req.emr_out_length = MC_CMD_SET_MAC_OUT_LEN; 3149573ed00SAndrew Rybchenko 3159573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_IN_MTU, epp->ep_mac_pdu); 3169573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_IN_DRAIN, epp->ep_mac_drain ? 1 : 0); 3179573ed00SAndrew Rybchenko EFX_MAC_ADDR_COPY(MCDI_IN2(req, uint8_t, SET_MAC_IN_ADDR), 3189573ed00SAndrew Rybchenko epp->ep_mac_addr); 3199573ed00SAndrew Rybchenko 3209573ed00SAndrew Rybchenko /* 3219573ed00SAndrew Rybchenko * Note: The Huntington MAC does not support REJECT_BRDCST. 3229573ed00SAndrew Rybchenko * The REJECT_UNCST flag will also prevent multicast traffic 3239573ed00SAndrew Rybchenko * from reaching the filters. As Huntington filters drop any 3249573ed00SAndrew Rybchenko * traffic that does not match a filter it is ok to leave the 3259573ed00SAndrew Rybchenko * MAC running in promiscuous mode. See bug41141. 3269573ed00SAndrew Rybchenko * 3279573ed00SAndrew Rybchenko * FIXME: Does REJECT_UNCST behave the same way on Medford? 3289573ed00SAndrew Rybchenko */ 3299573ed00SAndrew Rybchenko MCDI_IN_POPULATE_DWORD_2(req, SET_MAC_IN_REJECT, 3309573ed00SAndrew Rybchenko SET_MAC_IN_REJECT_UNCST, 0, 3319573ed00SAndrew Rybchenko SET_MAC_IN_REJECT_BRDCST, 0); 3329573ed00SAndrew Rybchenko 3339573ed00SAndrew Rybchenko /* 3349573ed00SAndrew Rybchenko * Flow control, whether it is auto-negotiated or not, 3359573ed00SAndrew Rybchenko * is set via the PHY advertised capabilities. When set to 3369573ed00SAndrew Rybchenko * automatic the MAC will use the PHY settings to determine 3379573ed00SAndrew Rybchenko * the flow control settings. 3389573ed00SAndrew Rybchenko */ 3399573ed00SAndrew Rybchenko MCDI_IN_SET_DWORD(req, SET_MAC_IN_FCNTL, MC_CMD_FCNTL_AUTO); 3409573ed00SAndrew Rybchenko 3419573ed00SAndrew Rybchenko /* Do not include the Ethernet frame checksum in RX packets */ 3429573ed00SAndrew Rybchenko MCDI_IN_POPULATE_DWORD_1(req, SET_MAC_IN_FLAGS, 3439573ed00SAndrew Rybchenko SET_MAC_IN_FLAG_INCLUDE_FCS, 0); 3449573ed00SAndrew Rybchenko 3459573ed00SAndrew Rybchenko efx_mcdi_execute_quiet(enp, &req); 3469573ed00SAndrew Rybchenko 3479573ed00SAndrew Rybchenko if (req.emr_rc != 0) { 3489573ed00SAndrew Rybchenko /* 3499573ed00SAndrew Rybchenko * Unprivileged functions cannot control link state, 3509573ed00SAndrew Rybchenko * but still need to configure filters. 3519573ed00SAndrew Rybchenko */ 3529573ed00SAndrew Rybchenko if (req.emr_rc != EACCES) { 3539573ed00SAndrew Rybchenko rc = req.emr_rc; 3549573ed00SAndrew Rybchenko goto fail1; 3559573ed00SAndrew Rybchenko } 3569573ed00SAndrew Rybchenko } 3579573ed00SAndrew Rybchenko 3589573ed00SAndrew Rybchenko /* 3599573ed00SAndrew Rybchenko * Apply the filters for the MAC configuration. 3609573ed00SAndrew Rybchenko * If the NIC isn't ready to accept filters this may 3619573ed00SAndrew Rybchenko * return success without setting anything. 3629573ed00SAndrew Rybchenko */ 3639573ed00SAndrew Rybchenko rc = efx_filter_reconfigure(enp, epp->ep_mac_addr, 3649573ed00SAndrew Rybchenko epp->ep_all_unicst, epp->ep_mulcst, 3659573ed00SAndrew Rybchenko epp->ep_all_mulcst, epp->ep_brdcst, 3669573ed00SAndrew Rybchenko epp->ep_mulcst_addr_list, 3679573ed00SAndrew Rybchenko epp->ep_mulcst_addr_count); 3689573ed00SAndrew Rybchenko 3699573ed00SAndrew Rybchenko return (0); 3709573ed00SAndrew Rybchenko 3719573ed00SAndrew Rybchenko fail1: 3729573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 3739573ed00SAndrew Rybchenko 3749573ed00SAndrew Rybchenko return (rc); 3759573ed00SAndrew Rybchenko } 3769573ed00SAndrew Rybchenko 3779573ed00SAndrew Rybchenko __checkReturn efx_rc_t 3789573ed00SAndrew Rybchenko ef10_mac_multicast_list_set( 3799573ed00SAndrew Rybchenko __in efx_nic_t *enp) 3809573ed00SAndrew Rybchenko { 3819573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 3829573ed00SAndrew Rybchenko const efx_mac_ops_t *emop = epp->ep_emop; 3839573ed00SAndrew Rybchenko efx_rc_t rc; 3849573ed00SAndrew Rybchenko 3859573ed00SAndrew Rybchenko EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || 386cbc3f94fSAndrew Rybchenko enp->en_family == EFX_FAMILY_MEDFORD || 387cbc3f94fSAndrew Rybchenko enp->en_family == EFX_FAMILY_MEDFORD2); 3889573ed00SAndrew Rybchenko 3899573ed00SAndrew Rybchenko if ((rc = emop->emo_reconfigure(enp)) != 0) 3909573ed00SAndrew Rybchenko goto fail1; 3919573ed00SAndrew Rybchenko 3929573ed00SAndrew Rybchenko return (0); 3939573ed00SAndrew Rybchenko 3949573ed00SAndrew Rybchenko fail1: 3959573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 3969573ed00SAndrew Rybchenko 3979573ed00SAndrew Rybchenko return (rc); 3989573ed00SAndrew Rybchenko } 3999573ed00SAndrew Rybchenko 4009573ed00SAndrew Rybchenko __checkReturn efx_rc_t 4019573ed00SAndrew Rybchenko ef10_mac_filter_default_rxq_set( 4029573ed00SAndrew Rybchenko __in efx_nic_t *enp, 4039573ed00SAndrew Rybchenko __in efx_rxq_t *erp, 4049573ed00SAndrew Rybchenko __in boolean_t using_rss) 4059573ed00SAndrew Rybchenko { 4069573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 4079573ed00SAndrew Rybchenko efx_rxq_t *old_rxq; 4089573ed00SAndrew Rybchenko boolean_t old_using_rss; 4099573ed00SAndrew Rybchenko efx_rc_t rc; 4109573ed00SAndrew Rybchenko 4119573ed00SAndrew Rybchenko ef10_filter_get_default_rxq(enp, &old_rxq, &old_using_rss); 4129573ed00SAndrew Rybchenko 4139573ed00SAndrew Rybchenko ef10_filter_default_rxq_set(enp, erp, using_rss); 4149573ed00SAndrew Rybchenko 4159573ed00SAndrew Rybchenko rc = efx_filter_reconfigure(enp, epp->ep_mac_addr, 4169573ed00SAndrew Rybchenko epp->ep_all_unicst, epp->ep_mulcst, 4179573ed00SAndrew Rybchenko epp->ep_all_mulcst, epp->ep_brdcst, 4189573ed00SAndrew Rybchenko epp->ep_mulcst_addr_list, 4199573ed00SAndrew Rybchenko epp->ep_mulcst_addr_count); 4209573ed00SAndrew Rybchenko 4219573ed00SAndrew Rybchenko if (rc != 0) 4229573ed00SAndrew Rybchenko goto fail1; 4239573ed00SAndrew Rybchenko 4249573ed00SAndrew Rybchenko return (0); 4259573ed00SAndrew Rybchenko 4269573ed00SAndrew Rybchenko fail1: 4279573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 4289573ed00SAndrew Rybchenko 4299573ed00SAndrew Rybchenko ef10_filter_default_rxq_set(enp, old_rxq, old_using_rss); 4309573ed00SAndrew Rybchenko 4319573ed00SAndrew Rybchenko return (rc); 4329573ed00SAndrew Rybchenko } 4339573ed00SAndrew Rybchenko 4349573ed00SAndrew Rybchenko void 4359573ed00SAndrew Rybchenko ef10_mac_filter_default_rxq_clear( 4369573ed00SAndrew Rybchenko __in efx_nic_t *enp) 4379573ed00SAndrew Rybchenko { 4389573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 4399573ed00SAndrew Rybchenko 4409573ed00SAndrew Rybchenko ef10_filter_default_rxq_clear(enp); 4419573ed00SAndrew Rybchenko 4429573ed00SAndrew Rybchenko efx_filter_reconfigure(enp, epp->ep_mac_addr, 4439573ed00SAndrew Rybchenko epp->ep_all_unicst, epp->ep_mulcst, 4449573ed00SAndrew Rybchenko epp->ep_all_mulcst, epp->ep_brdcst, 4459573ed00SAndrew Rybchenko epp->ep_mulcst_addr_list, 4469573ed00SAndrew Rybchenko epp->ep_mulcst_addr_count); 4479573ed00SAndrew Rybchenko } 4489573ed00SAndrew Rybchenko 4499573ed00SAndrew Rybchenko 4509573ed00SAndrew Rybchenko #if EFSYS_OPT_LOOPBACK 4519573ed00SAndrew Rybchenko 4529573ed00SAndrew Rybchenko __checkReturn efx_rc_t 4539573ed00SAndrew Rybchenko ef10_mac_loopback_set( 4549573ed00SAndrew Rybchenko __in efx_nic_t *enp, 4559573ed00SAndrew Rybchenko __in efx_link_mode_t link_mode, 4569573ed00SAndrew Rybchenko __in efx_loopback_type_t loopback_type) 4579573ed00SAndrew Rybchenko { 4589573ed00SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 4599573ed00SAndrew Rybchenko const efx_phy_ops_t *epop = epp->ep_epop; 4609573ed00SAndrew Rybchenko efx_loopback_type_t old_loopback_type; 4619573ed00SAndrew Rybchenko efx_link_mode_t old_loopback_link_mode; 4629573ed00SAndrew Rybchenko efx_rc_t rc; 4639573ed00SAndrew Rybchenko 4649573ed00SAndrew Rybchenko /* The PHY object handles this on EF10 */ 4659573ed00SAndrew Rybchenko old_loopback_type = epp->ep_loopback_type; 4669573ed00SAndrew Rybchenko old_loopback_link_mode = epp->ep_loopback_link_mode; 4679573ed00SAndrew Rybchenko epp->ep_loopback_type = loopback_type; 4689573ed00SAndrew Rybchenko epp->ep_loopback_link_mode = link_mode; 4699573ed00SAndrew Rybchenko 4709573ed00SAndrew Rybchenko if ((rc = epop->epo_reconfigure(enp)) != 0) 4719573ed00SAndrew Rybchenko goto fail1; 4729573ed00SAndrew Rybchenko 4739573ed00SAndrew Rybchenko return (0); 4749573ed00SAndrew Rybchenko 4759573ed00SAndrew Rybchenko fail1: 4769573ed00SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 4779573ed00SAndrew Rybchenko 4789573ed00SAndrew Rybchenko epp->ep_loopback_type = old_loopback_type; 4799573ed00SAndrew Rybchenko epp->ep_loopback_link_mode = old_loopback_link_mode; 4809573ed00SAndrew Rybchenko 4819573ed00SAndrew Rybchenko return (rc); 4829573ed00SAndrew Rybchenko } 4839573ed00SAndrew Rybchenko 4849573ed00SAndrew Rybchenko #endif /* EFSYS_OPT_LOOPBACK */ 4859573ed00SAndrew Rybchenko 4869573ed00SAndrew Rybchenko #if EFSYS_OPT_MAC_STATS 4879573ed00SAndrew Rybchenko 48858a72cb2SAndrew Rybchenko __checkReturn efx_rc_t 48958a72cb2SAndrew Rybchenko ef10_mac_stats_get_mask( 49058a72cb2SAndrew Rybchenko __in efx_nic_t *enp, 49158a72cb2SAndrew Rybchenko __inout_bcount(mask_size) uint32_t *maskp, 49258a72cb2SAndrew Rybchenko __in size_t mask_size) 49358a72cb2SAndrew Rybchenko { 49458a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_common[] = { 49558a72cb2SAndrew Rybchenko { EFX_MAC_RX_OCTETS, EFX_MAC_RX_GE_15XX_PKTS }, 49658a72cb2SAndrew Rybchenko { EFX_MAC_RX_FCS_ERRORS, EFX_MAC_RX_DROP_EVENTS }, 49758a72cb2SAndrew Rybchenko { EFX_MAC_RX_JABBER_PKTS, EFX_MAC_RX_JABBER_PKTS }, 49858a72cb2SAndrew Rybchenko { EFX_MAC_RX_NODESC_DROP_CNT, EFX_MAC_TX_PAUSE_PKTS }, 49958a72cb2SAndrew Rybchenko }; 50058a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_tx_size_bins[] = { 50158a72cb2SAndrew Rybchenko { EFX_MAC_TX_LE_64_PKTS, EFX_MAC_TX_GE_15XX_PKTS }, 50258a72cb2SAndrew Rybchenko }; 50358a72cb2SAndrew Rybchenko efx_nic_cfg_t *encp = &(enp->en_nic_cfg); 50458a72cb2SAndrew Rybchenko efx_port_t *epp = &(enp->en_port); 50558a72cb2SAndrew Rybchenko efx_rc_t rc; 50658a72cb2SAndrew Rybchenko 50758a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 50858a72cb2SAndrew Rybchenko ef10_common, EFX_ARRAY_SIZE(ef10_common))) != 0) 50958a72cb2SAndrew Rybchenko goto fail1; 51058a72cb2SAndrew Rybchenko 51158a72cb2SAndrew Rybchenko if (epp->ep_phy_cap_mask & (1 << MC_CMD_PHY_CAP_40000FDX_LBN)) { 51258a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_40g_extra[] = { 51358a72cb2SAndrew Rybchenko { EFX_MAC_RX_ALIGN_ERRORS, EFX_MAC_RX_ALIGN_ERRORS }, 51458a72cb2SAndrew Rybchenko }; 51558a72cb2SAndrew Rybchenko 51658a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 51758a72cb2SAndrew Rybchenko ef10_40g_extra, EFX_ARRAY_SIZE(ef10_40g_extra))) != 0) 51858a72cb2SAndrew Rybchenko goto fail2; 51958a72cb2SAndrew Rybchenko 52058a72cb2SAndrew Rybchenko if (encp->enc_mac_stats_40g_tx_size_bins) { 52158a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, 52258a72cb2SAndrew Rybchenko mask_size, ef10_tx_size_bins, 52358a72cb2SAndrew Rybchenko EFX_ARRAY_SIZE(ef10_tx_size_bins))) != 0) 52458a72cb2SAndrew Rybchenko goto fail3; 52558a72cb2SAndrew Rybchenko } 52658a72cb2SAndrew Rybchenko } else { 52758a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 52858a72cb2SAndrew Rybchenko ef10_tx_size_bins, EFX_ARRAY_SIZE(ef10_tx_size_bins))) != 0) 52958a72cb2SAndrew Rybchenko goto fail4; 53058a72cb2SAndrew Rybchenko } 53158a72cb2SAndrew Rybchenko 53258a72cb2SAndrew Rybchenko if (encp->enc_pm_and_rxdp_counters) { 53358a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_pm_and_rxdp[] = { 53458a72cb2SAndrew Rybchenko { EFX_MAC_PM_TRUNC_BB_OVERFLOW, EFX_MAC_RXDP_HLB_WAIT }, 53558a72cb2SAndrew Rybchenko }; 53658a72cb2SAndrew Rybchenko 53758a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 53858a72cb2SAndrew Rybchenko ef10_pm_and_rxdp, EFX_ARRAY_SIZE(ef10_pm_and_rxdp))) != 0) 53958a72cb2SAndrew Rybchenko goto fail5; 54058a72cb2SAndrew Rybchenko } 54158a72cb2SAndrew Rybchenko 54258a72cb2SAndrew Rybchenko if (encp->enc_datapath_cap_evb) { 54358a72cb2SAndrew Rybchenko const struct efx_mac_stats_range ef10_vadaptor[] = { 54458a72cb2SAndrew Rybchenko { EFX_MAC_VADAPTER_RX_UNICAST_PACKETS, 54558a72cb2SAndrew Rybchenko EFX_MAC_VADAPTER_TX_OVERFLOW }, 54658a72cb2SAndrew Rybchenko }; 54758a72cb2SAndrew Rybchenko 54858a72cb2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 54958a72cb2SAndrew Rybchenko ef10_vadaptor, EFX_ARRAY_SIZE(ef10_vadaptor))) != 0) 55058a72cb2SAndrew Rybchenko goto fail6; 55158a72cb2SAndrew Rybchenko } 55258a72cb2SAndrew Rybchenko 553747819d2SAndrew Rybchenko if (encp->enc_fec_counters) { 554747819d2SAndrew Rybchenko const struct efx_mac_stats_range ef10_fec[] = { 555747819d2SAndrew Rybchenko { EFX_MAC_FEC_UNCORRECTED_ERRORS, 556747819d2SAndrew Rybchenko EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE3 }, 557747819d2SAndrew Rybchenko }; 558747819d2SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 559747819d2SAndrew Rybchenko ef10_fec, EFX_ARRAY_SIZE(ef10_fec))) != 0) 560747819d2SAndrew Rybchenko goto fail7; 561747819d2SAndrew Rybchenko } 562747819d2SAndrew Rybchenko 563*ef8967c7SAndrew Rybchenko if (encp->enc_mac_stats_nstats >= MC_CMD_MAC_NSTATS_V4) { 564*ef8967c7SAndrew Rybchenko const struct efx_mac_stats_range ef10_rxdp_sdt[] = { 565*ef8967c7SAndrew Rybchenko { EFX_MAC_RXDP_SCATTER_DISABLED_TRUNC, 566*ef8967c7SAndrew Rybchenko EFX_MAC_RXDP_SCATTER_DISABLED_TRUNC }, 567*ef8967c7SAndrew Rybchenko }; 568*ef8967c7SAndrew Rybchenko 569*ef8967c7SAndrew Rybchenko if ((rc = efx_mac_stats_mask_add_ranges(maskp, mask_size, 570*ef8967c7SAndrew Rybchenko ef10_rxdp_sdt, EFX_ARRAY_SIZE(ef10_rxdp_sdt))) != 0) 571*ef8967c7SAndrew Rybchenko goto fail8; 572*ef8967c7SAndrew Rybchenko } 573*ef8967c7SAndrew Rybchenko 57458a72cb2SAndrew Rybchenko return (0); 57558a72cb2SAndrew Rybchenko 576*ef8967c7SAndrew Rybchenko fail8: 577*ef8967c7SAndrew Rybchenko EFSYS_PROBE(fail8); 578747819d2SAndrew Rybchenko fail7: 579747819d2SAndrew Rybchenko EFSYS_PROBE(fail7); 58058a72cb2SAndrew Rybchenko fail6: 58158a72cb2SAndrew Rybchenko EFSYS_PROBE(fail6); 58258a72cb2SAndrew Rybchenko fail5: 58358a72cb2SAndrew Rybchenko EFSYS_PROBE(fail5); 58458a72cb2SAndrew Rybchenko fail4: 58558a72cb2SAndrew Rybchenko EFSYS_PROBE(fail4); 58658a72cb2SAndrew Rybchenko fail3: 58758a72cb2SAndrew Rybchenko EFSYS_PROBE(fail3); 58858a72cb2SAndrew Rybchenko fail2: 58958a72cb2SAndrew Rybchenko EFSYS_PROBE(fail2); 59058a72cb2SAndrew Rybchenko fail1: 59158a72cb2SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 59258a72cb2SAndrew Rybchenko 59358a72cb2SAndrew Rybchenko return (rc); 59458a72cb2SAndrew Rybchenko } 59558a72cb2SAndrew Rybchenko 5969573ed00SAndrew Rybchenko #define EF10_MAC_STAT_READ(_esmp, _field, _eqp) \ 5979573ed00SAndrew Rybchenko EFSYS_MEM_READQ((_esmp), (_field) * sizeof (efx_qword_t), _eqp) 5989573ed00SAndrew Rybchenko 5999573ed00SAndrew Rybchenko 6009573ed00SAndrew Rybchenko __checkReturn efx_rc_t 6019573ed00SAndrew Rybchenko ef10_mac_stats_update( 6029573ed00SAndrew Rybchenko __in efx_nic_t *enp, 6039573ed00SAndrew Rybchenko __in efsys_mem_t *esmp, 6049573ed00SAndrew Rybchenko __inout_ecount(EFX_MAC_NSTATS) efsys_stat_t *stat, 6059573ed00SAndrew Rybchenko __inout_opt uint32_t *generationp) 6069573ed00SAndrew Rybchenko { 607fdfd8bfeSAndrew Rybchenko const efx_nic_cfg_t *encp = &enp->en_nic_cfg; 6089573ed00SAndrew Rybchenko efx_qword_t generation_start; 6099573ed00SAndrew Rybchenko efx_qword_t generation_end; 610fdfd8bfeSAndrew Rybchenko efx_qword_t value; 611fdfd8bfeSAndrew Rybchenko efx_rc_t rc; 6129573ed00SAndrew Rybchenko 613fdfd8bfeSAndrew Rybchenko /* 614fdfd8bfeSAndrew Rybchenko * The MAC_STATS contain start and end generation counters used to 615fdfd8bfeSAndrew Rybchenko * detect when the DMA buffer has been updated during stats decode. 616fdfd8bfeSAndrew Rybchenko * All stats counters are 64bit unsigned values. 617fdfd8bfeSAndrew Rybchenko * 618fdfd8bfeSAndrew Rybchenko * Siena-compatible MAC stats contain MC_CMD_MAC_NSTATS 64bit counters. 619fdfd8bfeSAndrew Rybchenko * The generation end counter is at index MC_CMD_MAC_GENERATION_END 620fdfd8bfeSAndrew Rybchenko * (same as MC_CMD_MAC_NSTATS-1). 621fdfd8bfeSAndrew Rybchenko * 622fdfd8bfeSAndrew Rybchenko * Medford2 and later use a larger DMA buffer: MAC_STATS_NUM_STATS from 623fdfd8bfeSAndrew Rybchenko * MC_CMD_GET_CAPABILITIES_V4_OUT reports the number of 64bit counters. 624fdfd8bfeSAndrew Rybchenko * 625fdfd8bfeSAndrew Rybchenko * Firmware writes the generation end counter as the last counter in the 626fdfd8bfeSAndrew Rybchenko * DMA buffer. Do not use MC_CMD_MAC_GENERATION_END, as that is only 627fdfd8bfeSAndrew Rybchenko * correct for legacy Siena-compatible MAC stats. 628fdfd8bfeSAndrew Rybchenko */ 629fdfd8bfeSAndrew Rybchenko 630fdfd8bfeSAndrew Rybchenko if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS) { 631fdfd8bfeSAndrew Rybchenko /* MAC stats count too small for legacy MAC stats */ 632fdfd8bfeSAndrew Rybchenko rc = ENOSPC; 633fdfd8bfeSAndrew Rybchenko goto fail1; 634fdfd8bfeSAndrew Rybchenko } 635fdfd8bfeSAndrew Rybchenko if (EFSYS_MEM_SIZE(esmp) < 636fdfd8bfeSAndrew Rybchenko (encp->enc_mac_stats_nstats * sizeof (efx_qword_t))) { 637fdfd8bfeSAndrew Rybchenko /* DMA buffer too small */ 638fdfd8bfeSAndrew Rybchenko rc = ENOSPC; 639fdfd8bfeSAndrew Rybchenko goto fail2; 640fdfd8bfeSAndrew Rybchenko } 6419573ed00SAndrew Rybchenko 6429573ed00SAndrew Rybchenko /* Read END first so we don't race with the MC */ 643fdfd8bfeSAndrew Rybchenko EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp)); 644fdfd8bfeSAndrew Rybchenko EF10_MAC_STAT_READ(esmp, (encp->enc_mac_stats_nstats - 1), 6459573ed00SAndrew Rybchenko &generation_end); 6469573ed00SAndrew Rybchenko EFSYS_MEM_READ_BARRIER(); 6479573ed00SAndrew Rybchenko 6489573ed00SAndrew Rybchenko /* TX */ 6499573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_PKTS, &value); 6509573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_PKTS]), &value); 6519573ed00SAndrew Rybchenko 6529573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_CONTROL_PKTS, &value); 6539573ed00SAndrew Rybchenko EFSYS_STAT_SUBR_QWORD(&(stat[EFX_MAC_TX_PKTS]), &value); 6549573ed00SAndrew Rybchenko 6559573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_PAUSE_PKTS, &value); 6569573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_PAUSE_PKTS]), &value); 6579573ed00SAndrew Rybchenko 6589573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_UNICAST_PKTS, &value); 6599573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_UNICST_PKTS]), &value); 6609573ed00SAndrew Rybchenko 6619573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_MULTICAST_PKTS, &value); 6629573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_MULTICST_PKTS]), &value); 6639573ed00SAndrew Rybchenko 6649573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_BROADCAST_PKTS, &value); 6659573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_BRDCST_PKTS]), &value); 6669573ed00SAndrew Rybchenko 6679573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_BYTES, &value); 6689573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_OCTETS]), &value); 6699573ed00SAndrew Rybchenko 6709573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_LT64_PKTS, &value); 6719573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_LE_64_PKTS]), &value); 6729573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_64_PKTS, &value); 6739573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_LE_64_PKTS]), &value); 6749573ed00SAndrew Rybchenko 6759573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_65_TO_127_PKTS, &value); 6769573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_65_TO_127_PKTS]), &value); 6779573ed00SAndrew Rybchenko 6789573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_128_TO_255_PKTS, &value); 6799573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_128_TO_255_PKTS]), &value); 6809573ed00SAndrew Rybchenko 6819573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_256_TO_511_PKTS, &value); 6829573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_256_TO_511_PKTS]), &value); 6839573ed00SAndrew Rybchenko 6849573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_512_TO_1023_PKTS, &value); 6859573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_512_TO_1023_PKTS]), &value); 6869573ed00SAndrew Rybchenko 6879573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_1024_TO_15XX_PKTS, &value); 6889573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_1024_TO_15XX_PKTS]), &value); 6899573ed00SAndrew Rybchenko 6909573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_15XX_TO_JUMBO_PKTS, &value); 6919573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_GE_15XX_PKTS]), &value); 6929573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_GTJUMBO_PKTS, &value); 6939573ed00SAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_TX_GE_15XX_PKTS]), &value); 6949573ed00SAndrew Rybchenko 6959573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_BAD_FCS_PKTS, &value); 6969573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_ERRORS]), &value); 6979573ed00SAndrew Rybchenko 6989573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_SINGLE_COLLISION_PKTS, &value); 6999573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_SGL_COL_PKTS]), &value); 7009573ed00SAndrew Rybchenko 7019573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_MULTIPLE_COLLISION_PKTS, 7029573ed00SAndrew Rybchenko &value); 7039573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_MULT_COL_PKTS]), &value); 7049573ed00SAndrew Rybchenko 7059573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_EXCESSIVE_COLLISION_PKTS, 7069573ed00SAndrew Rybchenko &value); 7079573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_EX_COL_PKTS]), &value); 7089573ed00SAndrew Rybchenko 7099573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_LATE_COLLISION_PKTS, &value); 7109573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_LATE_COL_PKTS]), &value); 7119573ed00SAndrew Rybchenko 7129573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_DEFERRED_PKTS, &value); 7139573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_DEF_PKTS]), &value); 7149573ed00SAndrew Rybchenko 7159573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_EXCESSIVE_DEFERRED_PKTS, 7169573ed00SAndrew Rybchenko &value); 7179573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_EX_DEF_PKTS]), &value); 7189573ed00SAndrew Rybchenko 7199573ed00SAndrew Rybchenko /* RX */ 7209573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_BYTES, &value); 7219573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_OCTETS]), &value); 7229573ed00SAndrew Rybchenko 7239573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_PKTS, &value); 7249573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_PKTS]), &value); 7259573ed00SAndrew Rybchenko 7269573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_UNICAST_PKTS, &value); 7279573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_UNICST_PKTS]), &value); 7289573ed00SAndrew Rybchenko 7299573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_MULTICAST_PKTS, &value); 7309573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_MULTICST_PKTS]), &value); 7319573ed00SAndrew Rybchenko 7329573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_BROADCAST_PKTS, &value); 7339573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_BRDCST_PKTS]), &value); 7349573ed00SAndrew Rybchenko 7359573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_PAUSE_PKTS, &value); 7369573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_PAUSE_PKTS]), &value); 7379573ed00SAndrew Rybchenko 7389573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_UNDERSIZE_PKTS, &value); 7399573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_LE_64_PKTS]), &value); 7409573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_64_PKTS, &value); 7419573ed00SAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_RX_LE_64_PKTS]), &value); 7429573ed00SAndrew Rybchenko 7439573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_65_TO_127_PKTS, &value); 7449573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_65_TO_127_PKTS]), &value); 7459573ed00SAndrew Rybchenko 7469573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_128_TO_255_PKTS, &value); 7479573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_128_TO_255_PKTS]), &value); 7489573ed00SAndrew Rybchenko 7499573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_256_TO_511_PKTS, &value); 7509573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_256_TO_511_PKTS]), &value); 7519573ed00SAndrew Rybchenko 7529573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_512_TO_1023_PKTS, &value); 7539573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_512_TO_1023_PKTS]), &value); 7549573ed00SAndrew Rybchenko 7559573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_1024_TO_15XX_PKTS, &value); 7569573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_1024_TO_15XX_PKTS]), &value); 7579573ed00SAndrew Rybchenko 7589573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_15XX_TO_JUMBO_PKTS, &value); 7599573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_GE_15XX_PKTS]), &value); 7609573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_GTJUMBO_PKTS, &value); 7619573ed00SAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_RX_GE_15XX_PKTS]), &value); 7629573ed00SAndrew Rybchenko 7639573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_BAD_FCS_PKTS, &value); 7649573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_FCS_ERRORS]), &value); 7659573ed00SAndrew Rybchenko 7669573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_OVERFLOW_PKTS, &value); 7679573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_DROP_EVENTS]), &value); 7689573ed00SAndrew Rybchenko 7699573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_FALSE_CARRIER_PKTS, &value); 7709573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_FALSE_CARRIER_ERRORS]), &value); 7719573ed00SAndrew Rybchenko 7729573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_SYMBOL_ERROR_PKTS, &value); 7739573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_SYMBOL_ERRORS]), &value); 7749573ed00SAndrew Rybchenko 7759573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_ALIGN_ERROR_PKTS, &value); 7769573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_ALIGN_ERRORS]), &value); 7779573ed00SAndrew Rybchenko 7789573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_INTERNAL_ERROR_PKTS, &value); 7799573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_INTERNAL_ERRORS]), &value); 7809573ed00SAndrew Rybchenko 7819573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_JABBER_PKTS, &value); 7829573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_JABBER_PKTS]), &value); 7839573ed00SAndrew Rybchenko 7849573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES01_CHAR_ERR, &value); 7859573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE0_CHAR_ERR]), 7869573ed00SAndrew Rybchenko &(value.eq_dword[0])); 7879573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE1_CHAR_ERR]), 7889573ed00SAndrew Rybchenko &(value.eq_dword[1])); 7899573ed00SAndrew Rybchenko 7909573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES23_CHAR_ERR, &value); 7919573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE2_CHAR_ERR]), 7929573ed00SAndrew Rybchenko &(value.eq_dword[0])); 7939573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE3_CHAR_ERR]), 7949573ed00SAndrew Rybchenko &(value.eq_dword[1])); 7959573ed00SAndrew Rybchenko 7969573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES01_DISP_ERR, &value); 7979573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE0_DISP_ERR]), 7989573ed00SAndrew Rybchenko &(value.eq_dword[0])); 7999573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE1_DISP_ERR]), 8009573ed00SAndrew Rybchenko &(value.eq_dword[1])); 8019573ed00SAndrew Rybchenko 8029573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES23_DISP_ERR, &value); 8039573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE2_DISP_ERR]), 8049573ed00SAndrew Rybchenko &(value.eq_dword[0])); 8059573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE3_DISP_ERR]), 8069573ed00SAndrew Rybchenko &(value.eq_dword[1])); 8079573ed00SAndrew Rybchenko 8089573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_MATCH_FAULT, &value); 8099573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_MATCH_FAULT]), &value); 8109573ed00SAndrew Rybchenko 8119573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_NODESC_DROPS, &value); 8129573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_NODESC_DROP_CNT]), &value); 8139573ed00SAndrew Rybchenko 8149573ed00SAndrew Rybchenko /* Packet memory (EF10 only) */ 8159573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_TRUNC_BB_OVERFLOW, &value); 8169573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_TRUNC_BB_OVERFLOW]), &value); 8179573ed00SAndrew Rybchenko 8189573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_BB_OVERFLOW, &value); 8199573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_BB_OVERFLOW]), &value); 8209573ed00SAndrew Rybchenko 8219573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_TRUNC_VFIFO_FULL, &value); 8229573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_TRUNC_VFIFO_FULL]), &value); 8239573ed00SAndrew Rybchenko 8249573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_VFIFO_FULL, &value); 8259573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_VFIFO_FULL]), &value); 8269573ed00SAndrew Rybchenko 8279573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_TRUNC_QBB, &value); 8289573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_TRUNC_QBB]), &value); 8299573ed00SAndrew Rybchenko 8309573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_QBB, &value); 8319573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_QBB]), &value); 8329573ed00SAndrew Rybchenko 8339573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_MAPPING, &value); 8349573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_MAPPING]), &value); 8359573ed00SAndrew Rybchenko 8369573ed00SAndrew Rybchenko /* RX datapath */ 8379573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_Q_DISABLED_PKTS, &value); 8389573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_Q_DISABLED_PKTS]), &value); 8399573ed00SAndrew Rybchenko 8409573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_DI_DROPPED_PKTS, &value); 8419573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_DI_DROPPED_PKTS]), &value); 8429573ed00SAndrew Rybchenko 8439573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_STREAMING_PKTS, &value); 8449573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_STREAMING_PKTS]), &value); 8459573ed00SAndrew Rybchenko 8469573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_HLB_FETCH_CONDITIONS, &value); 8479573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_HLB_FETCH]), &value); 8489573ed00SAndrew Rybchenko 8499573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_HLB_WAIT_CONDITIONS, &value); 8509573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_HLB_WAIT]), &value); 8519573ed00SAndrew Rybchenko 8529573ed00SAndrew Rybchenko 8539573ed00SAndrew Rybchenko /* VADAPTER RX */ 8549573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_UNICAST_PACKETS, 8559573ed00SAndrew Rybchenko &value); 8569573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_UNICAST_PACKETS]), 8579573ed00SAndrew Rybchenko &value); 8589573ed00SAndrew Rybchenko 8599573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_UNICAST_BYTES, 8609573ed00SAndrew Rybchenko &value); 8619573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_UNICAST_BYTES]), 8629573ed00SAndrew Rybchenko &value); 8639573ed00SAndrew Rybchenko 8649573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_MULTICAST_PACKETS, 8659573ed00SAndrew Rybchenko &value); 8669573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_MULTICAST_PACKETS]), 8679573ed00SAndrew Rybchenko &value); 8689573ed00SAndrew Rybchenko 8699573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_MULTICAST_BYTES, 8709573ed00SAndrew Rybchenko &value); 8719573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_MULTICAST_BYTES]), 8729573ed00SAndrew Rybchenko &value); 8739573ed00SAndrew Rybchenko 8749573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BROADCAST_PACKETS, 8759573ed00SAndrew Rybchenko &value); 8769573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BROADCAST_PACKETS]), 8779573ed00SAndrew Rybchenko &value); 8789573ed00SAndrew Rybchenko 8799573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BROADCAST_BYTES, 8809573ed00SAndrew Rybchenko &value); 8819573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BROADCAST_BYTES]), 8829573ed00SAndrew Rybchenko &value); 8839573ed00SAndrew Rybchenko 8849573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BAD_PACKETS, 8859573ed00SAndrew Rybchenko &value); 8869573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BAD_PACKETS]), 8879573ed00SAndrew Rybchenko &value); 8889573ed00SAndrew Rybchenko 8899573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BAD_BYTES, &value); 8909573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BAD_BYTES]), &value); 8919573ed00SAndrew Rybchenko 8929573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_OVERFLOW, &value); 8939573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_OVERFLOW]), &value); 8949573ed00SAndrew Rybchenko 8959573ed00SAndrew Rybchenko /* VADAPTER TX */ 8969573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_UNICAST_PACKETS, 8979573ed00SAndrew Rybchenko &value); 8989573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_UNICAST_PACKETS]), 8999573ed00SAndrew Rybchenko &value); 9009573ed00SAndrew Rybchenko 9019573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_UNICAST_BYTES, 9029573ed00SAndrew Rybchenko &value); 9039573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_UNICAST_BYTES]), 9049573ed00SAndrew Rybchenko &value); 9059573ed00SAndrew Rybchenko 9069573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_MULTICAST_PACKETS, 9079573ed00SAndrew Rybchenko &value); 9089573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_MULTICAST_PACKETS]), 9099573ed00SAndrew Rybchenko &value); 9109573ed00SAndrew Rybchenko 9119573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_MULTICAST_BYTES, 9129573ed00SAndrew Rybchenko &value); 9139573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_MULTICAST_BYTES]), 9149573ed00SAndrew Rybchenko &value); 9159573ed00SAndrew Rybchenko 9169573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BROADCAST_PACKETS, 9179573ed00SAndrew Rybchenko &value); 9189573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BROADCAST_PACKETS]), 9199573ed00SAndrew Rybchenko &value); 9209573ed00SAndrew Rybchenko 9219573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BROADCAST_BYTES, 9229573ed00SAndrew Rybchenko &value); 9239573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BROADCAST_BYTES]), 9249573ed00SAndrew Rybchenko &value); 9259573ed00SAndrew Rybchenko 9269573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BAD_PACKETS, &value); 9279573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BAD_PACKETS]), &value); 9289573ed00SAndrew Rybchenko 9299573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BAD_BYTES, &value); 9309573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BAD_BYTES]), &value); 9319573ed00SAndrew Rybchenko 9329573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_OVERFLOW, &value); 9339573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_OVERFLOW]), &value); 9349573ed00SAndrew Rybchenko 935747819d2SAndrew Rybchenko 936747819d2SAndrew Rybchenko if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS_V2) 937747819d2SAndrew Rybchenko goto done; 938747819d2SAndrew Rybchenko 939747819d2SAndrew Rybchenko /* FEC */ 940747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_UNCORRECTED_ERRORS, &value); 941747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_UNCORRECTED_ERRORS]), &value); 942747819d2SAndrew Rybchenko 943747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_ERRORS, &value); 944747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_ERRORS]), &value); 945747819d2SAndrew Rybchenko 946747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_SYMBOLS_LANE0, 947747819d2SAndrew Rybchenko &value); 948747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE0]), 949747819d2SAndrew Rybchenko &value); 950747819d2SAndrew Rybchenko 951747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_SYMBOLS_LANE1, 952747819d2SAndrew Rybchenko &value); 953747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE1]), 954747819d2SAndrew Rybchenko &value); 955747819d2SAndrew Rybchenko 956747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_SYMBOLS_LANE2, 957747819d2SAndrew Rybchenko &value); 958747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE2]), 959747819d2SAndrew Rybchenko &value); 960747819d2SAndrew Rybchenko 961747819d2SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_FEC_CORRECTED_SYMBOLS_LANE3, 962747819d2SAndrew Rybchenko &value); 963747819d2SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_FEC_CORRECTED_SYMBOLS_LANE3]), 964747819d2SAndrew Rybchenko &value); 965747819d2SAndrew Rybchenko 96674d36c84SAndrew Rybchenko if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS_V3) 96774d36c84SAndrew Rybchenko goto done; 96874d36c84SAndrew Rybchenko 96974d36c84SAndrew Rybchenko /* CTPIO exceptions */ 97074d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_VI_BUSY_FALLBACK, &value); 97174d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_VI_BUSY_FALLBACK]), &value); 97274d36c84SAndrew Rybchenko 97374d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_LONG_WRITE_SUCCESS, &value); 97474d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_LONG_WRITE_SUCCESS]), &value); 97574d36c84SAndrew Rybchenko 97674d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_MISSING_DBELL_FAIL, &value); 97774d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_MISSING_DBELL_FAIL]), &value); 97874d36c84SAndrew Rybchenko 97974d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_OVERFLOW_FAIL, &value); 98074d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_OVERFLOW_FAIL]), &value); 98174d36c84SAndrew Rybchenko 98274d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_UNDERFLOW_FAIL, &value); 98374d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_UNDERFLOW_FAIL]), &value); 98474d36c84SAndrew Rybchenko 98574d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_TIMEOUT_FAIL, &value); 98674d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_TIMEOUT_FAIL]), &value); 98774d36c84SAndrew Rybchenko 98874d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_NONCONTIG_WR_FAIL, &value); 98974d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_NONCONTIG_WR_FAIL]), &value); 99074d36c84SAndrew Rybchenko 99174d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_FRM_CLOBBER_FAIL, &value); 99274d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_FRM_CLOBBER_FAIL]), &value); 99374d36c84SAndrew Rybchenko 99474d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_INVALID_WR_FAIL, &value); 99574d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_INVALID_WR_FAIL]), &value); 99674d36c84SAndrew Rybchenko 99774d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_VI_CLOBBER_FALLBACK, &value); 99874d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_VI_CLOBBER_FALLBACK]), 99974d36c84SAndrew Rybchenko &value); 100074d36c84SAndrew Rybchenko 100174d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_UNQUALIFIED_FALLBACK, &value); 100274d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_UNQUALIFIED_FALLBACK]), 100374d36c84SAndrew Rybchenko &value); 100474d36c84SAndrew Rybchenko 100574d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_RUNT_FALLBACK, &value); 100674d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_RUNT_FALLBACK]), &value); 100774d36c84SAndrew Rybchenko 100874d36c84SAndrew Rybchenko /* CTPIO per-port stats */ 100974d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_SUCCESS, &value); 101074d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_SUCCESS]), &value); 101174d36c84SAndrew Rybchenko 101274d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_FALLBACK, &value); 101374d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_FALLBACK]), &value); 101474d36c84SAndrew Rybchenko 101574d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_POISON, &value); 101674d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_POISON]), &value); 101774d36c84SAndrew Rybchenko 101874d36c84SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_CTPIO_ERASE, &value); 101974d36c84SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_CTPIO_ERASE]), &value); 102074d36c84SAndrew Rybchenko 1021*ef8967c7SAndrew Rybchenko if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS_V4) 1022*ef8967c7SAndrew Rybchenko goto done; 1023*ef8967c7SAndrew Rybchenko 1024*ef8967c7SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_SCATTER_DISABLED_TRUNC, 1025*ef8967c7SAndrew Rybchenko &value); 1026*ef8967c7SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_SCATTER_DISABLED_TRUNC]), 1027*ef8967c7SAndrew Rybchenko &value); 1028*ef8967c7SAndrew Rybchenko 1029747819d2SAndrew Rybchenko done: 1030fdfd8bfeSAndrew Rybchenko /* Read START generation counter */ 1031fdfd8bfeSAndrew Rybchenko EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp)); 10329573ed00SAndrew Rybchenko EFSYS_MEM_READ_BARRIER(); 10339573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_GENERATION_START, 10349573ed00SAndrew Rybchenko &generation_start); 10359573ed00SAndrew Rybchenko 10369573ed00SAndrew Rybchenko /* Check that we didn't read the stats in the middle of a DMA */ 10379573ed00SAndrew Rybchenko /* Not a good enough check ? */ 10389573ed00SAndrew Rybchenko if (memcmp(&generation_start, &generation_end, 10399573ed00SAndrew Rybchenko sizeof (generation_start))) 10409573ed00SAndrew Rybchenko return (EAGAIN); 10419573ed00SAndrew Rybchenko 10429573ed00SAndrew Rybchenko if (generationp) 10439573ed00SAndrew Rybchenko *generationp = EFX_QWORD_FIELD(generation_start, EFX_DWORD_0); 10449573ed00SAndrew Rybchenko 10459573ed00SAndrew Rybchenko return (0); 1046fdfd8bfeSAndrew Rybchenko 1047fdfd8bfeSAndrew Rybchenko fail2: 1048fdfd8bfeSAndrew Rybchenko EFSYS_PROBE(fail2); 1049fdfd8bfeSAndrew Rybchenko fail1: 1050fdfd8bfeSAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 1051fdfd8bfeSAndrew Rybchenko 1052fdfd8bfeSAndrew Rybchenko return (rc); 10539573ed00SAndrew Rybchenko } 10549573ed00SAndrew Rybchenko 10559573ed00SAndrew Rybchenko #endif /* EFSYS_OPT_MAC_STATS */ 10569573ed00SAndrew Rybchenko 1057cbc3f94fSAndrew Rybchenko #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */ 1058