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 55358a72cb2SAndrew Rybchenko return (0); 55458a72cb2SAndrew Rybchenko 55558a72cb2SAndrew Rybchenko fail6: 55658a72cb2SAndrew Rybchenko EFSYS_PROBE(fail6); 55758a72cb2SAndrew Rybchenko fail5: 55858a72cb2SAndrew Rybchenko EFSYS_PROBE(fail5); 55958a72cb2SAndrew Rybchenko fail4: 56058a72cb2SAndrew Rybchenko EFSYS_PROBE(fail4); 56158a72cb2SAndrew Rybchenko fail3: 56258a72cb2SAndrew Rybchenko EFSYS_PROBE(fail3); 56358a72cb2SAndrew Rybchenko fail2: 56458a72cb2SAndrew Rybchenko EFSYS_PROBE(fail2); 56558a72cb2SAndrew Rybchenko fail1: 56658a72cb2SAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 56758a72cb2SAndrew Rybchenko 56858a72cb2SAndrew Rybchenko return (rc); 56958a72cb2SAndrew Rybchenko } 57058a72cb2SAndrew Rybchenko 5719573ed00SAndrew Rybchenko #define EF10_MAC_STAT_READ(_esmp, _field, _eqp) \ 5729573ed00SAndrew Rybchenko EFSYS_MEM_READQ((_esmp), (_field) * sizeof (efx_qword_t), _eqp) 5739573ed00SAndrew Rybchenko 5749573ed00SAndrew Rybchenko 5759573ed00SAndrew Rybchenko __checkReturn efx_rc_t 5769573ed00SAndrew Rybchenko ef10_mac_stats_update( 5779573ed00SAndrew Rybchenko __in efx_nic_t *enp, 5789573ed00SAndrew Rybchenko __in efsys_mem_t *esmp, 5799573ed00SAndrew Rybchenko __inout_ecount(EFX_MAC_NSTATS) efsys_stat_t *stat, 5809573ed00SAndrew Rybchenko __inout_opt uint32_t *generationp) 5819573ed00SAndrew Rybchenko { 582*fdfd8bfeSAndrew Rybchenko const efx_nic_cfg_t *encp = &enp->en_nic_cfg; 5839573ed00SAndrew Rybchenko efx_qword_t generation_start; 5849573ed00SAndrew Rybchenko efx_qword_t generation_end; 585*fdfd8bfeSAndrew Rybchenko efx_qword_t value; 586*fdfd8bfeSAndrew Rybchenko efx_rc_t rc; 5879573ed00SAndrew Rybchenko 588*fdfd8bfeSAndrew Rybchenko /* 589*fdfd8bfeSAndrew Rybchenko * The MAC_STATS contain start and end generation counters used to 590*fdfd8bfeSAndrew Rybchenko * detect when the DMA buffer has been updated during stats decode. 591*fdfd8bfeSAndrew Rybchenko * All stats counters are 64bit unsigned values. 592*fdfd8bfeSAndrew Rybchenko * 593*fdfd8bfeSAndrew Rybchenko * Siena-compatible MAC stats contain MC_CMD_MAC_NSTATS 64bit counters. 594*fdfd8bfeSAndrew Rybchenko * The generation end counter is at index MC_CMD_MAC_GENERATION_END 595*fdfd8bfeSAndrew Rybchenko * (same as MC_CMD_MAC_NSTATS-1). 596*fdfd8bfeSAndrew Rybchenko * 597*fdfd8bfeSAndrew Rybchenko * Medford2 and later use a larger DMA buffer: MAC_STATS_NUM_STATS from 598*fdfd8bfeSAndrew Rybchenko * MC_CMD_GET_CAPABILITIES_V4_OUT reports the number of 64bit counters. 599*fdfd8bfeSAndrew Rybchenko * 600*fdfd8bfeSAndrew Rybchenko * Firmware writes the generation end counter as the last counter in the 601*fdfd8bfeSAndrew Rybchenko * DMA buffer. Do not use MC_CMD_MAC_GENERATION_END, as that is only 602*fdfd8bfeSAndrew Rybchenko * correct for legacy Siena-compatible MAC stats. 603*fdfd8bfeSAndrew Rybchenko */ 604*fdfd8bfeSAndrew Rybchenko 605*fdfd8bfeSAndrew Rybchenko if (encp->enc_mac_stats_nstats < MC_CMD_MAC_NSTATS) { 606*fdfd8bfeSAndrew Rybchenko /* MAC stats count too small for legacy MAC stats */ 607*fdfd8bfeSAndrew Rybchenko rc = ENOSPC; 608*fdfd8bfeSAndrew Rybchenko goto fail1; 609*fdfd8bfeSAndrew Rybchenko } 610*fdfd8bfeSAndrew Rybchenko if (EFSYS_MEM_SIZE(esmp) < 611*fdfd8bfeSAndrew Rybchenko (encp->enc_mac_stats_nstats * sizeof (efx_qword_t))) { 612*fdfd8bfeSAndrew Rybchenko /* DMA buffer too small */ 613*fdfd8bfeSAndrew Rybchenko rc = ENOSPC; 614*fdfd8bfeSAndrew Rybchenko goto fail2; 615*fdfd8bfeSAndrew Rybchenko } 6169573ed00SAndrew Rybchenko 6179573ed00SAndrew Rybchenko /* Read END first so we don't race with the MC */ 618*fdfd8bfeSAndrew Rybchenko EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp)); 619*fdfd8bfeSAndrew Rybchenko EF10_MAC_STAT_READ(esmp, (encp->enc_mac_stats_nstats - 1), 6209573ed00SAndrew Rybchenko &generation_end); 6219573ed00SAndrew Rybchenko EFSYS_MEM_READ_BARRIER(); 6229573ed00SAndrew Rybchenko 6239573ed00SAndrew Rybchenko /* TX */ 6249573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_PKTS, &value); 6259573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_PKTS]), &value); 6269573ed00SAndrew Rybchenko 6279573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_CONTROL_PKTS, &value); 6289573ed00SAndrew Rybchenko EFSYS_STAT_SUBR_QWORD(&(stat[EFX_MAC_TX_PKTS]), &value); 6299573ed00SAndrew Rybchenko 6309573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_PAUSE_PKTS, &value); 6319573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_PAUSE_PKTS]), &value); 6329573ed00SAndrew Rybchenko 6339573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_UNICAST_PKTS, &value); 6349573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_UNICST_PKTS]), &value); 6359573ed00SAndrew Rybchenko 6369573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_MULTICAST_PKTS, &value); 6379573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_MULTICST_PKTS]), &value); 6389573ed00SAndrew Rybchenko 6399573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_BROADCAST_PKTS, &value); 6409573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_BRDCST_PKTS]), &value); 6419573ed00SAndrew Rybchenko 6429573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_BYTES, &value); 6439573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_OCTETS]), &value); 6449573ed00SAndrew Rybchenko 6459573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_LT64_PKTS, &value); 6469573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_LE_64_PKTS]), &value); 6479573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_64_PKTS, &value); 6489573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_LE_64_PKTS]), &value); 6499573ed00SAndrew Rybchenko 6509573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_65_TO_127_PKTS, &value); 6519573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_65_TO_127_PKTS]), &value); 6529573ed00SAndrew Rybchenko 6539573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_128_TO_255_PKTS, &value); 6549573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_128_TO_255_PKTS]), &value); 6559573ed00SAndrew Rybchenko 6569573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_256_TO_511_PKTS, &value); 6579573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_256_TO_511_PKTS]), &value); 6589573ed00SAndrew Rybchenko 6599573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_512_TO_1023_PKTS, &value); 6609573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_512_TO_1023_PKTS]), &value); 6619573ed00SAndrew Rybchenko 6629573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_1024_TO_15XX_PKTS, &value); 6639573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_1024_TO_15XX_PKTS]), &value); 6649573ed00SAndrew Rybchenko 6659573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_15XX_TO_JUMBO_PKTS, &value); 6669573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_GE_15XX_PKTS]), &value); 6679573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_GTJUMBO_PKTS, &value); 6689573ed00SAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_TX_GE_15XX_PKTS]), &value); 6699573ed00SAndrew Rybchenko 6709573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_BAD_FCS_PKTS, &value); 6719573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_ERRORS]), &value); 6729573ed00SAndrew Rybchenko 6739573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_SINGLE_COLLISION_PKTS, &value); 6749573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_SGL_COL_PKTS]), &value); 6759573ed00SAndrew Rybchenko 6769573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_MULTIPLE_COLLISION_PKTS, 6779573ed00SAndrew Rybchenko &value); 6789573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_MULT_COL_PKTS]), &value); 6799573ed00SAndrew Rybchenko 6809573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_EXCESSIVE_COLLISION_PKTS, 6819573ed00SAndrew Rybchenko &value); 6829573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_EX_COL_PKTS]), &value); 6839573ed00SAndrew Rybchenko 6849573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_LATE_COLLISION_PKTS, &value); 6859573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_LATE_COL_PKTS]), &value); 6869573ed00SAndrew Rybchenko 6879573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_DEFERRED_PKTS, &value); 6889573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_DEF_PKTS]), &value); 6899573ed00SAndrew Rybchenko 6909573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_TX_EXCESSIVE_DEFERRED_PKTS, 6919573ed00SAndrew Rybchenko &value); 6929573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_TX_EX_DEF_PKTS]), &value); 6939573ed00SAndrew Rybchenko 6949573ed00SAndrew Rybchenko /* RX */ 6959573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_BYTES, &value); 6969573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_OCTETS]), &value); 6979573ed00SAndrew Rybchenko 6989573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_PKTS, &value); 6999573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_PKTS]), &value); 7009573ed00SAndrew Rybchenko 7019573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_UNICAST_PKTS, &value); 7029573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_UNICST_PKTS]), &value); 7039573ed00SAndrew Rybchenko 7049573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_MULTICAST_PKTS, &value); 7059573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_MULTICST_PKTS]), &value); 7069573ed00SAndrew Rybchenko 7079573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_BROADCAST_PKTS, &value); 7089573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_BRDCST_PKTS]), &value); 7099573ed00SAndrew Rybchenko 7109573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_PAUSE_PKTS, &value); 7119573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_PAUSE_PKTS]), &value); 7129573ed00SAndrew Rybchenko 7139573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_UNDERSIZE_PKTS, &value); 7149573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_LE_64_PKTS]), &value); 7159573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_64_PKTS, &value); 7169573ed00SAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_RX_LE_64_PKTS]), &value); 7179573ed00SAndrew Rybchenko 7189573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_65_TO_127_PKTS, &value); 7199573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_65_TO_127_PKTS]), &value); 7209573ed00SAndrew Rybchenko 7219573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_128_TO_255_PKTS, &value); 7229573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_128_TO_255_PKTS]), &value); 7239573ed00SAndrew Rybchenko 7249573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_256_TO_511_PKTS, &value); 7259573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_256_TO_511_PKTS]), &value); 7269573ed00SAndrew Rybchenko 7279573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_512_TO_1023_PKTS, &value); 7289573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_512_TO_1023_PKTS]), &value); 7299573ed00SAndrew Rybchenko 7309573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_1024_TO_15XX_PKTS, &value); 7319573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_1024_TO_15XX_PKTS]), &value); 7329573ed00SAndrew Rybchenko 7339573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_15XX_TO_JUMBO_PKTS, &value); 7349573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_GE_15XX_PKTS]), &value); 7359573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_GTJUMBO_PKTS, &value); 7369573ed00SAndrew Rybchenko EFSYS_STAT_INCR_QWORD(&(stat[EFX_MAC_RX_GE_15XX_PKTS]), &value); 7379573ed00SAndrew Rybchenko 7389573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_BAD_FCS_PKTS, &value); 7399573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_FCS_ERRORS]), &value); 7409573ed00SAndrew Rybchenko 7419573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_OVERFLOW_PKTS, &value); 7429573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_DROP_EVENTS]), &value); 7439573ed00SAndrew Rybchenko 7449573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_FALSE_CARRIER_PKTS, &value); 7459573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_FALSE_CARRIER_ERRORS]), &value); 7469573ed00SAndrew Rybchenko 7479573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_SYMBOL_ERROR_PKTS, &value); 7489573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_SYMBOL_ERRORS]), &value); 7499573ed00SAndrew Rybchenko 7509573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_ALIGN_ERROR_PKTS, &value); 7519573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_ALIGN_ERRORS]), &value); 7529573ed00SAndrew Rybchenko 7539573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_INTERNAL_ERROR_PKTS, &value); 7549573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_INTERNAL_ERRORS]), &value); 7559573ed00SAndrew Rybchenko 7569573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_JABBER_PKTS, &value); 7579573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_JABBER_PKTS]), &value); 7589573ed00SAndrew Rybchenko 7599573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES01_CHAR_ERR, &value); 7609573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE0_CHAR_ERR]), 7619573ed00SAndrew Rybchenko &(value.eq_dword[0])); 7629573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE1_CHAR_ERR]), 7639573ed00SAndrew Rybchenko &(value.eq_dword[1])); 7649573ed00SAndrew Rybchenko 7659573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES23_CHAR_ERR, &value); 7669573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE2_CHAR_ERR]), 7679573ed00SAndrew Rybchenko &(value.eq_dword[0])); 7689573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE3_CHAR_ERR]), 7699573ed00SAndrew Rybchenko &(value.eq_dword[1])); 7709573ed00SAndrew Rybchenko 7719573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES01_DISP_ERR, &value); 7729573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE0_DISP_ERR]), 7739573ed00SAndrew Rybchenko &(value.eq_dword[0])); 7749573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE1_DISP_ERR]), 7759573ed00SAndrew Rybchenko &(value.eq_dword[1])); 7769573ed00SAndrew Rybchenko 7779573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_LANES23_DISP_ERR, &value); 7789573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE2_DISP_ERR]), 7799573ed00SAndrew Rybchenko &(value.eq_dword[0])); 7809573ed00SAndrew Rybchenko EFSYS_STAT_SET_DWORD(&(stat[EFX_MAC_RX_LANE3_DISP_ERR]), 7819573ed00SAndrew Rybchenko &(value.eq_dword[1])); 7829573ed00SAndrew Rybchenko 7839573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_MATCH_FAULT, &value); 7849573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_MATCH_FAULT]), &value); 7859573ed00SAndrew Rybchenko 7869573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_NODESC_DROPS, &value); 7879573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_NODESC_DROP_CNT]), &value); 7889573ed00SAndrew Rybchenko 7899573ed00SAndrew Rybchenko /* Packet memory (EF10 only) */ 7909573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_TRUNC_BB_OVERFLOW, &value); 7919573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_TRUNC_BB_OVERFLOW]), &value); 7929573ed00SAndrew Rybchenko 7939573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_BB_OVERFLOW, &value); 7949573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_BB_OVERFLOW]), &value); 7959573ed00SAndrew Rybchenko 7969573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_TRUNC_VFIFO_FULL, &value); 7979573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_TRUNC_VFIFO_FULL]), &value); 7989573ed00SAndrew Rybchenko 7999573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_VFIFO_FULL, &value); 8009573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_VFIFO_FULL]), &value); 8019573ed00SAndrew Rybchenko 8029573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_TRUNC_QBB, &value); 8039573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_TRUNC_QBB]), &value); 8049573ed00SAndrew Rybchenko 8059573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_QBB, &value); 8069573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_QBB]), &value); 8079573ed00SAndrew Rybchenko 8089573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_PM_DISCARD_MAPPING, &value); 8099573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_PM_DISCARD_MAPPING]), &value); 8109573ed00SAndrew Rybchenko 8119573ed00SAndrew Rybchenko /* RX datapath */ 8129573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_Q_DISABLED_PKTS, &value); 8139573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_Q_DISABLED_PKTS]), &value); 8149573ed00SAndrew Rybchenko 8159573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_DI_DROPPED_PKTS, &value); 8169573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_DI_DROPPED_PKTS]), &value); 8179573ed00SAndrew Rybchenko 8189573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_STREAMING_PKTS, &value); 8199573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_STREAMING_PKTS]), &value); 8209573ed00SAndrew Rybchenko 8219573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_HLB_FETCH_CONDITIONS, &value); 8229573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_HLB_FETCH]), &value); 8239573ed00SAndrew Rybchenko 8249573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_RXDP_HLB_WAIT_CONDITIONS, &value); 8259573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RXDP_HLB_WAIT]), &value); 8269573ed00SAndrew Rybchenko 8279573ed00SAndrew Rybchenko 8289573ed00SAndrew Rybchenko /* VADAPTER RX */ 8299573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_UNICAST_PACKETS, 8309573ed00SAndrew Rybchenko &value); 8319573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_UNICAST_PACKETS]), 8329573ed00SAndrew Rybchenko &value); 8339573ed00SAndrew Rybchenko 8349573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_UNICAST_BYTES, 8359573ed00SAndrew Rybchenko &value); 8369573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_UNICAST_BYTES]), 8379573ed00SAndrew Rybchenko &value); 8389573ed00SAndrew Rybchenko 8399573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_MULTICAST_PACKETS, 8409573ed00SAndrew Rybchenko &value); 8419573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_MULTICAST_PACKETS]), 8429573ed00SAndrew Rybchenko &value); 8439573ed00SAndrew Rybchenko 8449573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_MULTICAST_BYTES, 8459573ed00SAndrew Rybchenko &value); 8469573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_MULTICAST_BYTES]), 8479573ed00SAndrew Rybchenko &value); 8489573ed00SAndrew Rybchenko 8499573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BROADCAST_PACKETS, 8509573ed00SAndrew Rybchenko &value); 8519573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BROADCAST_PACKETS]), 8529573ed00SAndrew Rybchenko &value); 8539573ed00SAndrew Rybchenko 8549573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BROADCAST_BYTES, 8559573ed00SAndrew Rybchenko &value); 8569573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BROADCAST_BYTES]), 8579573ed00SAndrew Rybchenko &value); 8589573ed00SAndrew Rybchenko 8599573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BAD_PACKETS, 8609573ed00SAndrew Rybchenko &value); 8619573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BAD_PACKETS]), 8629573ed00SAndrew Rybchenko &value); 8639573ed00SAndrew Rybchenko 8649573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_BAD_BYTES, &value); 8659573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_BAD_BYTES]), &value); 8669573ed00SAndrew Rybchenko 8679573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_RX_OVERFLOW, &value); 8689573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_RX_OVERFLOW]), &value); 8699573ed00SAndrew Rybchenko 8709573ed00SAndrew Rybchenko /* VADAPTER TX */ 8719573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_UNICAST_PACKETS, 8729573ed00SAndrew Rybchenko &value); 8739573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_UNICAST_PACKETS]), 8749573ed00SAndrew Rybchenko &value); 8759573ed00SAndrew Rybchenko 8769573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_UNICAST_BYTES, 8779573ed00SAndrew Rybchenko &value); 8789573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_UNICAST_BYTES]), 8799573ed00SAndrew Rybchenko &value); 8809573ed00SAndrew Rybchenko 8819573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_MULTICAST_PACKETS, 8829573ed00SAndrew Rybchenko &value); 8839573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_MULTICAST_PACKETS]), 8849573ed00SAndrew Rybchenko &value); 8859573ed00SAndrew Rybchenko 8869573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_MULTICAST_BYTES, 8879573ed00SAndrew Rybchenko &value); 8889573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_MULTICAST_BYTES]), 8899573ed00SAndrew Rybchenko &value); 8909573ed00SAndrew Rybchenko 8919573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BROADCAST_PACKETS, 8929573ed00SAndrew Rybchenko &value); 8939573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BROADCAST_PACKETS]), 8949573ed00SAndrew Rybchenko &value); 8959573ed00SAndrew Rybchenko 8969573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BROADCAST_BYTES, 8979573ed00SAndrew Rybchenko &value); 8989573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BROADCAST_BYTES]), 8999573ed00SAndrew Rybchenko &value); 9009573ed00SAndrew Rybchenko 9019573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BAD_PACKETS, &value); 9029573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BAD_PACKETS]), &value); 9039573ed00SAndrew Rybchenko 9049573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_BAD_BYTES, &value); 9059573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_BAD_BYTES]), &value); 9069573ed00SAndrew Rybchenko 9079573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_VADAPTER_TX_OVERFLOW, &value); 9089573ed00SAndrew Rybchenko EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_VADAPTER_TX_OVERFLOW]), &value); 9099573ed00SAndrew Rybchenko 910*fdfd8bfeSAndrew Rybchenko /* Read START generation counter */ 911*fdfd8bfeSAndrew Rybchenko EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp)); 9129573ed00SAndrew Rybchenko EFSYS_MEM_READ_BARRIER(); 9139573ed00SAndrew Rybchenko EF10_MAC_STAT_READ(esmp, MC_CMD_MAC_GENERATION_START, 9149573ed00SAndrew Rybchenko &generation_start); 9159573ed00SAndrew Rybchenko 9169573ed00SAndrew Rybchenko /* Check that we didn't read the stats in the middle of a DMA */ 9179573ed00SAndrew Rybchenko /* Not a good enough check ? */ 9189573ed00SAndrew Rybchenko if (memcmp(&generation_start, &generation_end, 9199573ed00SAndrew Rybchenko sizeof (generation_start))) 9209573ed00SAndrew Rybchenko return (EAGAIN); 9219573ed00SAndrew Rybchenko 9229573ed00SAndrew Rybchenko if (generationp) 9239573ed00SAndrew Rybchenko *generationp = EFX_QWORD_FIELD(generation_start, EFX_DWORD_0); 9249573ed00SAndrew Rybchenko 9259573ed00SAndrew Rybchenko return (0); 926*fdfd8bfeSAndrew Rybchenko 927*fdfd8bfeSAndrew Rybchenko fail2: 928*fdfd8bfeSAndrew Rybchenko EFSYS_PROBE(fail2); 929*fdfd8bfeSAndrew Rybchenko fail1: 930*fdfd8bfeSAndrew Rybchenko EFSYS_PROBE1(fail1, efx_rc_t, rc); 931*fdfd8bfeSAndrew Rybchenko 932*fdfd8bfeSAndrew Rybchenko return (rc); 9339573ed00SAndrew Rybchenko } 9349573ed00SAndrew Rybchenko 9359573ed00SAndrew Rybchenko #endif /* EFSYS_OPT_MAC_STATS */ 9369573ed00SAndrew Rybchenko 937cbc3f94fSAndrew Rybchenko #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */ 938