Lines Matching +full:5 +full:gbase +full:- +full:x

1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2014-2016 Broadcom Corporation
4 * Copyright (c) 2016-2017 Broadcom Limited
42 return bp->msg_enable; in bnxt_get_msglevel()
49 bp->msg_enable = value; in bnxt_set_msglevel()
63 coal->use_adaptive_rx_coalesce = bp->flags & BNXT_FLAG_DIM; in bnxt_get_coalesce()
65 hw_coal = &bp->rx_coal; in bnxt_get_coalesce()
66 mult = hw_coal->bufs_per_record; in bnxt_get_coalesce()
67 coal->rx_coalesce_usecs = hw_coal->coal_ticks; in bnxt_get_coalesce()
68 coal->rx_max_coalesced_frames = hw_coal->coal_bufs / mult; in bnxt_get_coalesce()
69 coal->rx_coalesce_usecs_irq = hw_coal->coal_ticks_irq; in bnxt_get_coalesce()
70 coal->rx_max_coalesced_frames_irq = hw_coal->coal_bufs_irq / mult; in bnxt_get_coalesce()
72 hw_coal = &bp->tx_coal; in bnxt_get_coalesce()
73 mult = hw_coal->bufs_per_record; in bnxt_get_coalesce()
74 coal->tx_coalesce_usecs = hw_coal->coal_ticks; in bnxt_get_coalesce()
75 coal->tx_max_coalesced_frames = hw_coal->coal_bufs / mult; in bnxt_get_coalesce()
76 coal->tx_coalesce_usecs_irq = hw_coal->coal_ticks_irq; in bnxt_get_coalesce()
77 coal->tx_max_coalesced_frames_irq = hw_coal->coal_bufs_irq / mult; in bnxt_get_coalesce()
79 coal->stats_block_coalesce_usecs = bp->stats_coal_ticks; in bnxt_get_coalesce()
95 if (coal->use_adaptive_rx_coalesce) { in bnxt_set_coalesce()
96 bp->flags |= BNXT_FLAG_DIM; in bnxt_set_coalesce()
98 if (bp->flags & BNXT_FLAG_DIM) { in bnxt_set_coalesce()
99 bp->flags &= ~(BNXT_FLAG_DIM); in bnxt_set_coalesce()
104 hw_coal = &bp->rx_coal; in bnxt_set_coalesce()
105 mult = hw_coal->bufs_per_record; in bnxt_set_coalesce()
106 hw_coal->coal_ticks = coal->rx_coalesce_usecs; in bnxt_set_coalesce()
107 hw_coal->coal_bufs = coal->rx_max_coalesced_frames * mult; in bnxt_set_coalesce()
108 hw_coal->coal_ticks_irq = coal->rx_coalesce_usecs_irq; in bnxt_set_coalesce()
109 hw_coal->coal_bufs_irq = coal->rx_max_coalesced_frames_irq * mult; in bnxt_set_coalesce()
111 hw_coal = &bp->tx_coal; in bnxt_set_coalesce()
112 mult = hw_coal->bufs_per_record; in bnxt_set_coalesce()
113 hw_coal->coal_ticks = coal->tx_coalesce_usecs; in bnxt_set_coalesce()
114 hw_coal->coal_bufs = coal->tx_max_coalesced_frames * mult; in bnxt_set_coalesce()
115 hw_coal->coal_ticks_irq = coal->tx_coalesce_usecs_irq; in bnxt_set_coalesce()
116 hw_coal->coal_bufs_irq = coal->tx_max_coalesced_frames_irq * mult; in bnxt_set_coalesce()
118 if (bp->stats_coal_ticks != coal->stats_block_coalesce_usecs) { in bnxt_set_coalesce()
119 u32 stats_ticks = coal->stats_block_coalesce_usecs; in bnxt_set_coalesce()
127 bp->stats_coal_ticks = stats_ticks; in bnxt_set_coalesce()
128 if (bp->stats_coal_ticks) in bnxt_set_coalesce()
129 bp->current_interval = in bnxt_set_coalesce()
130 bp->stats_coal_ticks * HZ / 1000000; in bnxt_set_coalesce()
132 bp->current_interval = BNXT_TIMER_INTERVAL; in bnxt_set_coalesce()
224 BNXT_RX_STATS_EXT_PFC_ENTRY(5), \
234 BNXT_TX_STATS_EXT_PFC_ENTRY(5), \
252 BNXT_RX_STATS_EXT_COS_ENTRY(5), \
262 BNXT_TX_STATS_EXT_COS_ENTRY(5), \
276 BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(5), \
294 BNXT_RX_STATS_PRI_ENTRY(counter, 5), \
304 BNXT_TX_STATS_PRI_ENTRY(counter, 5), \
479 if (bp->max_tpa_v2) { in bnxt_get_num_tpa_ring_stats()
497 return rx * bp->rx_nr_rings + tx * bp->tx_nr_rings + in bnxt_get_num_ring_stats()
498 cmn * bp->cp_nr_rings; in bnxt_get_num_ring_stats()
507 if (bp->flags & BNXT_FLAG_PORT_STATS) in bnxt_get_num_stats()
510 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_get_num_stats()
511 num_stats += bp->fw_rx_stats_ext_size + in bnxt_get_num_stats()
512 bp->fw_tx_stats_ext_size; in bnxt_get_num_stats()
513 if (bp->pri2cos_valid) in bnxt_get_num_stats()
528 if (!bp->num_tests) in bnxt_get_sset_count()
529 return -EOPNOTSUPP; in bnxt_get_sset_count()
530 return bp->num_tests; in bnxt_get_sset_count()
532 return -EOPNOTSUPP; in bnxt_get_sset_count()
538 return ring_num < bp->rx_nr_rings; in is_rx_ring()
545 if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) in is_tx_ring()
546 tx_base = bp->rx_nr_rings; in is_tx_ring()
548 if (ring_num >= tx_base && ring_num < (tx_base + bp->tx_nr_rings)) in is_tx_ring()
560 if (!bp->bnapi) { in bnxt_get_ethtool_stats()
569 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_ethtool_stats()
570 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_get_ethtool_stats()
571 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_get_ethtool_stats()
572 u64 *sw_stats = cpr->stats.sw_stats; in bnxt_get_ethtool_stats()
595 sw = (u64 *)&cpr->sw_stats.rx; in bnxt_get_ethtool_stats()
601 sw = (u64 *)&cpr->sw_stats.cmn; in bnxt_get_ethtool_stats()
610 cpr->sw_stats.rx.rx_netpoll_discards; in bnxt_get_ethtool_stats()
617 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_ethtool_stats()
618 u64 *port_stats = bp->port_stats.sw_stats; in bnxt_get_ethtool_stats()
623 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_get_ethtool_stats()
624 u64 *rx_port_stats_ext = bp->rx_port_stats_ext.sw_stats; in bnxt_get_ethtool_stats()
625 u64 *tx_port_stats_ext = bp->tx_port_stats_ext.sw_stats; in bnxt_get_ethtool_stats()
627 for (i = 0; i < bp->fw_rx_stats_ext_size; i++, j++) { in bnxt_get_ethtool_stats()
631 for (i = 0; i < bp->fw_tx_stats_ext_size; i++, j++) { in bnxt_get_ethtool_stats()
635 if (bp->pri2cos_valid) { in bnxt_get_ethtool_stats()
638 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
644 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
650 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
656 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
672 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_strings()
693 if (bp->max_tpa_v2) in bnxt_get_strings()
723 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_strings()
729 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_get_strings()
730 for (i = 0; i < bp->fw_rx_stats_ext_size; i++) { in bnxt_get_strings()
734 for (i = 0; i < bp->fw_tx_stats_ext_size; i++) { in bnxt_get_strings()
739 if (bp->pri2cos_valid) { in bnxt_get_strings()
764 if (bp->num_tests) in bnxt_get_strings()
765 memcpy(buf, bp->test_info->string, in bnxt_get_strings()
766 bp->num_tests * ETH_GSTRING_LEN); in bnxt_get_strings()
769 netdev_err(bp->dev, "bnxt_get_strings invalid request %x\n", in bnxt_get_strings()
780 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in bnxt_get_ringparam()
781 ering->rx_max_pending = BNXT_MAX_RX_DESC_CNT_JUM_ENA; in bnxt_get_ringparam()
782 ering->rx_jumbo_max_pending = BNXT_MAX_RX_JUM_DESC_CNT; in bnxt_get_ringparam()
784 ering->rx_max_pending = BNXT_MAX_RX_DESC_CNT; in bnxt_get_ringparam()
785 ering->rx_jumbo_max_pending = 0; in bnxt_get_ringparam()
787 ering->tx_max_pending = BNXT_MAX_TX_DESC_CNT; in bnxt_get_ringparam()
789 ering->rx_pending = bp->rx_ring_size; in bnxt_get_ringparam()
790 ering->rx_jumbo_pending = bp->rx_agg_ring_size; in bnxt_get_ringparam()
791 ering->tx_pending = bp->tx_ring_size; in bnxt_get_ringparam()
799 if ((ering->rx_pending > BNXT_MAX_RX_DESC_CNT) || in bnxt_set_ringparam()
800 (ering->tx_pending > BNXT_MAX_TX_DESC_CNT) || in bnxt_set_ringparam()
801 (ering->tx_pending < BNXT_MIN_TX_DESC_CNT)) in bnxt_set_ringparam()
802 return -EINVAL; in bnxt_set_ringparam()
807 bp->rx_ring_size = ering->rx_pending; in bnxt_set_ringparam()
808 bp->tx_ring_size = ering->tx_pending; in bnxt_set_ringparam()
821 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_get_channels()
825 /* Get the most up-to-date max_tx_sch_inputs. */ in bnxt_get_channels()
828 max_tx_sch_inputs = hw_resc->max_tx_sch_inputs; in bnxt_get_channels()
836 if (bp->tx_nr_rings_xdp) in bnxt_get_channels()
839 channel->max_combined = min_t(int, max_rx_rings, max_tx_rings); in bnxt_get_channels()
851 channel->max_rx = max_rx_rings; in bnxt_get_channels()
852 channel->max_tx = max_tx_rings; in bnxt_get_channels()
853 channel->max_other = 0; in bnxt_get_channels()
854 if (bp->flags & BNXT_FLAG_SHARED_RINGS) { in bnxt_get_channels()
855 channel->combined_count = bp->rx_nr_rings; in bnxt_get_channels()
857 channel->combined_count--; in bnxt_get_channels()
860 channel->rx_count = bp->rx_nr_rings; in bnxt_get_channels()
861 channel->tx_count = bp->tx_nr_rings_per_tc; in bnxt_get_channels()
875 if (channel->other_count) in bnxt_set_channels()
876 return -EINVAL; in bnxt_set_channels()
878 if (!channel->combined_count && in bnxt_set_channels()
879 (!channel->rx_count || !channel->tx_count)) in bnxt_set_channels()
880 return -EINVAL; in bnxt_set_channels()
882 if (channel->combined_count && in bnxt_set_channels()
883 (channel->rx_count || channel->tx_count)) in bnxt_set_channels()
884 return -EINVAL; in bnxt_set_channels()
886 if (BNXT_CHIP_TYPE_NITRO_A0(bp) && (channel->rx_count || in bnxt_set_channels()
887 channel->tx_count)) in bnxt_set_channels()
888 return -EINVAL; in bnxt_set_channels()
890 if (channel->combined_count) in bnxt_set_channels()
895 req_tx_rings = sh ? channel->combined_count : channel->tx_count; in bnxt_set_channels()
896 req_rx_rings = sh ? channel->combined_count : channel->rx_count; in bnxt_set_channels()
897 if (bp->tx_nr_rings_xdp) { in bnxt_set_channels()
900 return -EINVAL; in bnxt_set_channels()
911 bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) && in bnxt_set_channels()
912 (dev->priv_flags & IFF_RXFH_CONFIGURED)) { in bnxt_set_channels()
914 return -EINVAL; in bnxt_set_channels()
925 netdev_err(bp->dev, "Set channel failure rc :%x\n", in bnxt_set_channels()
932 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_set_channels()
933 bp->rx_nr_rings = channel->combined_count; in bnxt_set_channels()
934 bp->tx_nr_rings_per_tc = channel->combined_count; in bnxt_set_channels()
936 bp->flags &= ~BNXT_FLAG_SHARED_RINGS; in bnxt_set_channels()
937 bp->rx_nr_rings = channel->rx_count; in bnxt_set_channels()
938 bp->tx_nr_rings_per_tc = channel->tx_count; in bnxt_set_channels()
940 bp->tx_nr_rings_xdp = tx_xdp; in bnxt_set_channels()
941 bp->tx_nr_rings = bp->tx_nr_rings_per_tc + tx_xdp; in bnxt_set_channels()
943 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs + tx_xdp; in bnxt_set_channels()
945 bp->cp_nr_rings = sh ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : in bnxt_set_channels()
946 bp->tx_nr_rings + bp->rx_nr_rings; in bnxt_set_channels()
970 cmd->data = bp->ntp_fltr_count; in bnxt_grxclsrlall()
975 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_grxclsrlall()
978 if (j == cmd->rule_cnt) in bnxt_grxclsrlall()
980 rule_locs[j++] = fltr->sw_id; in bnxt_grxclsrlall()
983 if (j == cmd->rule_cnt) in bnxt_grxclsrlall()
986 cmd->rule_cnt = j; in bnxt_grxclsrlall()
993 (struct ethtool_rx_flow_spec *)&cmd->fs; in bnxt_grxclsrule()
996 int i, rc = -EINVAL; in bnxt_grxclsrule()
998 if (fs->location >= BNXT_NTP_FLTR_MAX_FLTR) in bnxt_grxclsrule()
1004 head = &bp->ntp_fltr_hash_tbl[i]; in bnxt_grxclsrule()
1007 if (fltr->sw_id == fs->location) in bnxt_grxclsrule()
1015 fkeys = &fltr->fkeys; in bnxt_grxclsrule()
1016 if (fkeys->basic.n_proto == htons(ETH_P_IP)) { in bnxt_grxclsrule()
1017 if (fkeys->basic.ip_proto == IPPROTO_TCP) in bnxt_grxclsrule()
1018 fs->flow_type = TCP_V4_FLOW; in bnxt_grxclsrule()
1019 else if (fkeys->basic.ip_proto == IPPROTO_UDP) in bnxt_grxclsrule()
1020 fs->flow_type = UDP_V4_FLOW; in bnxt_grxclsrule()
1024 fs->h_u.tcp_ip4_spec.ip4src = fkeys->addrs.v4addrs.src; in bnxt_grxclsrule()
1025 fs->m_u.tcp_ip4_spec.ip4src = cpu_to_be32(~0); in bnxt_grxclsrule()
1027 fs->h_u.tcp_ip4_spec.ip4dst = fkeys->addrs.v4addrs.dst; in bnxt_grxclsrule()
1028 fs->m_u.tcp_ip4_spec.ip4dst = cpu_to_be32(~0); in bnxt_grxclsrule()
1030 fs->h_u.tcp_ip4_spec.psrc = fkeys->ports.src; in bnxt_grxclsrule()
1031 fs->m_u.tcp_ip4_spec.psrc = cpu_to_be16(~0); in bnxt_grxclsrule()
1033 fs->h_u.tcp_ip4_spec.pdst = fkeys->ports.dst; in bnxt_grxclsrule()
1034 fs->m_u.tcp_ip4_spec.pdst = cpu_to_be16(~0); in bnxt_grxclsrule()
1038 if (fkeys->basic.ip_proto == IPPROTO_TCP) in bnxt_grxclsrule()
1039 fs->flow_type = TCP_V6_FLOW; in bnxt_grxclsrule()
1040 else if (fkeys->basic.ip_proto == IPPROTO_UDP) in bnxt_grxclsrule()
1041 fs->flow_type = UDP_V6_FLOW; in bnxt_grxclsrule()
1045 *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6src[0] = in bnxt_grxclsrule()
1046 fkeys->addrs.v6addrs.src; in bnxt_grxclsrule()
1047 *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6dst[0] = in bnxt_grxclsrule()
1048 fkeys->addrs.v6addrs.dst; in bnxt_grxclsrule()
1050 fs->m_u.tcp_ip6_spec.ip6src[i] = cpu_to_be32(~0); in bnxt_grxclsrule()
1051 fs->m_u.tcp_ip6_spec.ip6dst[i] = cpu_to_be32(~0); in bnxt_grxclsrule()
1053 fs->h_u.tcp_ip6_spec.psrc = fkeys->ports.src; in bnxt_grxclsrule()
1054 fs->m_u.tcp_ip6_spec.psrc = cpu_to_be16(~0); in bnxt_grxclsrule()
1056 fs->h_u.tcp_ip6_spec.pdst = fkeys->ports.dst; in bnxt_grxclsrule()
1057 fs->m_u.tcp_ip6_spec.pdst = cpu_to_be16(~0); in bnxt_grxclsrule()
1060 fs->ring_cookie = fltr->rxq; in bnxt_grxclsrule()
1072 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4) in get_ethtool_ipv4_rss()
1079 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6) in get_ethtool_ipv6_rss()
1086 cmd->data = 0; in bnxt_grxfh()
1087 switch (cmd->flow_type) { in bnxt_grxfh()
1089 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4) in bnxt_grxfh()
1090 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1092 cmd->data |= get_ethtool_ipv4_rss(bp); in bnxt_grxfh()
1095 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4) in bnxt_grxfh()
1096 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1104 cmd->data |= get_ethtool_ipv4_rss(bp); in bnxt_grxfh()
1108 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6) in bnxt_grxfh()
1109 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1111 cmd->data |= get_ethtool_ipv6_rss(bp); in bnxt_grxfh()
1114 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6) in bnxt_grxfh()
1115 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1123 cmd->data |= get_ethtool_ipv6_rss(bp); in bnxt_grxfh()
1134 u32 rss_hash_cfg = bp->rss_hash_cfg; in bnxt_srxfh()
1137 if (cmd->data == RXH_4TUPLE) in bnxt_srxfh()
1139 else if (cmd->data == RXH_2TUPLE) in bnxt_srxfh()
1141 else if (!cmd->data) in bnxt_srxfh()
1144 return -EINVAL; in bnxt_srxfh()
1146 if (cmd->flow_type == TCP_V4_FLOW) { in bnxt_srxfh()
1150 } else if (cmd->flow_type == UDP_V4_FLOW) { in bnxt_srxfh()
1151 if (tuple == 4 && !(bp->flags & BNXT_FLAG_UDP_RSS_CAP)) in bnxt_srxfh()
1152 return -EINVAL; in bnxt_srxfh()
1156 } else if (cmd->flow_type == TCP_V6_FLOW) { in bnxt_srxfh()
1160 } else if (cmd->flow_type == UDP_V6_FLOW) { in bnxt_srxfh()
1161 if (tuple == 4 && !(bp->flags & BNXT_FLAG_UDP_RSS_CAP)) in bnxt_srxfh()
1162 return -EINVAL; in bnxt_srxfh()
1167 return -EINVAL; in bnxt_srxfh()
1170 switch (cmd->flow_type) { in bnxt_srxfh()
1198 if (bp->rss_hash_cfg == rss_hash_cfg) in bnxt_srxfh()
1201 bp->rss_hash_cfg = rss_hash_cfg; in bnxt_srxfh()
1202 if (netif_running(bp->dev)) { in bnxt_srxfh()
1215 switch (cmd->cmd) { in bnxt_get_rxnfc()
1218 cmd->data = bp->rx_nr_rings; in bnxt_get_rxnfc()
1222 cmd->rule_cnt = bp->ntp_fltr_count; in bnxt_get_rxnfc()
1223 cmd->data = BNXT_NTP_FLTR_MAX_FLTR; in bnxt_get_rxnfc()
1240 rc = -EOPNOTSUPP; in bnxt_get_rxnfc()
1252 switch (cmd->cmd) { in bnxt_set_rxnfc()
1258 rc = -EOPNOTSUPP; in bnxt_set_rxnfc()
1268 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_get_rxfh_indir_size()
1269 return ALIGN(bp->rx_nr_rings, BNXT_RSS_TABLE_ENTRIES_P5); in bnxt_get_rxfh_indir_size()
1288 if (!bp->vnic_info) in bnxt_get_rxfh()
1291 vnic = &bp->vnic_info[0]; in bnxt_get_rxfh()
1292 if (indir && bp->rss_indir_tbl) { in bnxt_get_rxfh()
1295 indir[i] = bp->rss_indir_tbl[i]; in bnxt_get_rxfh()
1298 if (key && vnic->rss_hash_key) in bnxt_get_rxfh()
1299 memcpy(key, vnic->rss_hash_key, HW_HASH_KEY_SIZE); in bnxt_get_rxfh()
1311 return -EOPNOTSUPP; in bnxt_set_rxfh()
1314 return -EOPNOTSUPP; in bnxt_set_rxfh()
1320 bp->rss_indir_tbl[i] = indir[i]; in bnxt_set_rxfh()
1321 pad = bp->rss_indir_tbl_entries - tbl_size; in bnxt_set_rxfh()
1323 memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); in bnxt_set_rxfh()
1326 if (netif_running(bp->dev)) { in bnxt_set_rxfh()
1338 strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); in bnxt_get_drvinfo()
1339 strlcpy(info->fw_version, bp->fw_ver_str, sizeof(info->fw_version)); in bnxt_get_drvinfo()
1340 strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info)); in bnxt_get_drvinfo()
1341 info->n_stats = bnxt_get_num_stats(bp); in bnxt_get_drvinfo()
1342 info->testinfo_len = bp->num_tests; in bnxt_get_drvinfo()
1344 info->eedump_len = 0; in bnxt_get_drvinfo()
1346 info->regdump_len = 0; in bnxt_get_drvinfo()
1355 return -EOPNOTSUPP; in bnxt_get_regs_len()
1359 if (bp->fw_cap & BNXT_FW_CAP_PCIE_STATS_SUPPORTED) in bnxt_get_regs_len()
1374 regs->version = 0; in bnxt_get_regs()
1377 if (!(bp->fw_cap & BNXT_FW_CAP_PCIE_STATS_SUPPORTED)) in bnxt_get_regs()
1390 regs->version = 1; in bnxt_get_regs()
1392 req->pcie_stat_size = cpu_to_le16(sizeof(*hw_pcie_stats)); in bnxt_get_regs()
1393 req->pcie_stat_host_addr = cpu_to_le64(hw_pcie_stats_addr); in bnxt_get_regs()
1410 wol->supported = 0; in bnxt_get_wol()
1411 wol->wolopts = 0; in bnxt_get_wol()
1412 memset(&wol->sopass, 0, sizeof(wol->sopass)); in bnxt_get_wol()
1413 if (bp->flags & BNXT_FLAG_WOL_CAP) { in bnxt_get_wol()
1414 wol->supported = WAKE_MAGIC; in bnxt_get_wol()
1415 if (bp->wol) in bnxt_get_wol()
1416 wol->wolopts = WAKE_MAGIC; in bnxt_get_wol()
1424 if (wol->wolopts & ~WAKE_MAGIC) in bnxt_set_wol()
1425 return -EINVAL; in bnxt_set_wol()
1427 if (wol->wolopts & WAKE_MAGIC) { in bnxt_set_wol()
1428 if (!(bp->flags & BNXT_FLAG_WOL_CAP)) in bnxt_set_wol()
1429 return -EINVAL; in bnxt_set_wol()
1430 if (!bp->wol) { in bnxt_set_wol()
1432 return -EBUSY; in bnxt_set_wol()
1433 bp->wol = 1; in bnxt_set_wol()
1436 if (bp->wol) { in bnxt_set_wol()
1438 return -EBUSY; in bnxt_set_wol()
1439 bp->wol = 0; in bnxt_set_wol()
1565 u16 fec_cfg = link_info->fec_cfg; in bnxt_fw_to_ethtool_advertised_fec()
1569 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
1574 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
1577 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
1580 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
1586 u16 fw_speeds = link_info->advertising; in bnxt_fw_to_ethtool_advertised_spds()
1589 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_fw_to_ethtool_advertised_spds()
1590 fw_pause = link_info->auto_pause_setting; in bnxt_fw_to_ethtool_advertised_spds()
1593 fw_speeds = link_info->advertising_pam4; in bnxt_fw_to_ethtool_advertised_spds()
1601 u16 fw_speeds = link_info->lp_auto_link_speeds; in bnxt_fw_to_ethtool_lp_adv()
1604 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_fw_to_ethtool_lp_adv()
1605 fw_pause = link_info->lp_pause; in bnxt_fw_to_ethtool_lp_adv()
1609 fw_speeds = link_info->lp_auto_pam4_link_speeds; in bnxt_fw_to_ethtool_lp_adv()
1616 u16 fec_cfg = link_info->fec_cfg; in bnxt_fw_to_ethtool_support_fec()
1620 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
1625 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
1628 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
1631 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
1637 u16 fw_speeds = link_info->support_speeds; in bnxt_fw_to_ethtool_support_spds()
1640 fw_speeds = link_info->support_pam4_speeds; in bnxt_fw_to_ethtool_support_spds()
1647 if (link_info->support_auto_speeds || in bnxt_fw_to_ethtool_support_spds()
1648 link_info->support_pam4_auto_speeds) in bnxt_fw_to_ethtool_support_spds()
1684 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_link_ksettings()
1685 struct ethtool_link_settings *base = &lk_ksettings->base; in bnxt_get_link_ksettings()
1689 mutex_lock(&bp->link_lock); in bnxt_get_link_ksettings()
1693 if (link_info->autoneg) { in bnxt_get_link_ksettings()
1697 base->autoneg = AUTONEG_ENABLE; in bnxt_get_link_ksettings()
1698 base->duplex = DUPLEX_UNKNOWN; in bnxt_get_link_ksettings()
1699 if (link_info->phy_link_status == BNXT_LINK_LINK) { in bnxt_get_link_ksettings()
1701 if (link_info->duplex & BNXT_LINK_DUPLEX_FULL) in bnxt_get_link_ksettings()
1702 base->duplex = DUPLEX_FULL; in bnxt_get_link_ksettings()
1704 base->duplex = DUPLEX_HALF; in bnxt_get_link_ksettings()
1706 ethtool_speed = bnxt_fw_to_ethtool_speed(link_info->link_speed); in bnxt_get_link_ksettings()
1708 base->autoneg = AUTONEG_DISABLE; in bnxt_get_link_ksettings()
1710 bnxt_fw_to_ethtool_speed(link_info->req_link_speed); in bnxt_get_link_ksettings()
1711 base->duplex = DUPLEX_HALF; in bnxt_get_link_ksettings()
1712 if (link_info->req_duplex == BNXT_LINK_DUPLEX_FULL) in bnxt_get_link_ksettings()
1713 base->duplex = DUPLEX_FULL; in bnxt_get_link_ksettings()
1715 base->speed = ethtool_speed; in bnxt_get_link_ksettings()
1717 base->port = PORT_NONE; in bnxt_get_link_ksettings()
1718 if (link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP) { in bnxt_get_link_ksettings()
1719 base->port = PORT_TP; in bnxt_get_link_ksettings()
1730 if (link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_DAC) in bnxt_get_link_ksettings()
1731 base->port = PORT_DA; in bnxt_get_link_ksettings()
1732 else if (link_info->media_type == in bnxt_get_link_ksettings()
1734 base->port = PORT_FIBRE; in bnxt_get_link_ksettings()
1736 base->phy_address = link_info->phy_addr; in bnxt_get_link_ksettings()
1737 mutex_unlock(&bp->link_lock); in bnxt_get_link_ksettings()
1745 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_force_link_speed()
1746 u16 support_pam4_spds = link_info->support_pam4_speeds; in bnxt_force_link_speed()
1747 u16 support_spds = link_info->support_speeds; in bnxt_force_link_speed()
1806 return -EINVAL; in bnxt_force_link_speed()
1809 if (link_info->req_link_speed == fw_speed && in bnxt_force_link_speed()
1810 link_info->req_signal_mode == sig_mode && in bnxt_force_link_speed()
1811 link_info->autoneg == 0) in bnxt_force_link_speed()
1812 return -EALREADY; in bnxt_force_link_speed()
1814 link_info->req_link_speed = fw_speed; in bnxt_force_link_speed()
1815 link_info->req_signal_mode = sig_mode; in bnxt_force_link_speed()
1816 link_info->req_duplex = BNXT_LINK_DUPLEX_FULL; in bnxt_force_link_speed()
1817 link_info->autoneg = 0; in bnxt_force_link_speed()
1818 link_info->advertising = 0; in bnxt_force_link_speed()
1819 link_info->advertising_pam4 = 0; in bnxt_force_link_speed()
1850 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_set_link_ksettings()
1851 const struct ethtool_link_settings *base = &lk_ksettings->base; in bnxt_set_link_ksettings()
1857 return -EOPNOTSUPP; in bnxt_set_link_ksettings()
1859 mutex_lock(&bp->link_lock); in bnxt_set_link_ksettings()
1860 if (base->autoneg == AUTONEG_ENABLE) { in bnxt_set_link_ksettings()
1861 link_info->advertising = 0; in bnxt_set_link_ksettings()
1862 link_info->advertising_pam4 = 0; in bnxt_set_link_ksettings()
1863 BNXT_ETHTOOL_TO_FW_SPDS(link_info->advertising, lk_ksettings, in bnxt_set_link_ksettings()
1865 BNXT_ETHTOOL_TO_FW_PAM4_SPDS(link_info->advertising_pam4, in bnxt_set_link_ksettings()
1867 link_info->autoneg |= BNXT_AUTONEG_SPEED; in bnxt_set_link_ksettings()
1868 if (!link_info->advertising && !link_info->advertising_pam4) { in bnxt_set_link_ksettings()
1869 link_info->advertising = link_info->support_auto_speeds; in bnxt_set_link_ksettings()
1870 link_info->advertising_pam4 = in bnxt_set_link_ksettings()
1871 link_info->support_pam4_auto_speeds; in bnxt_set_link_ksettings()
1878 u8 phy_type = link_info->phy_type; in bnxt_set_link_ksettings()
1882 link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP) { in bnxt_set_link_ksettings()
1883 netdev_err(dev, "10GBase-T devices must autoneg\n"); in bnxt_set_link_ksettings()
1884 rc = -EINVAL; in bnxt_set_link_ksettings()
1887 if (base->duplex == DUPLEX_HALF) { in bnxt_set_link_ksettings()
1889 rc = -EINVAL; in bnxt_set_link_ksettings()
1892 speed = base->speed; in bnxt_set_link_ksettings()
1895 if (rc == -EALREADY) in bnxt_set_link_ksettings()
1905 mutex_unlock(&bp->link_lock); in bnxt_set_link_ksettings()
1917 link_info = &bp->link_info; in bnxt_get_fecparam()
1918 fec_cfg = link_info->fec_cfg; in bnxt_get_fecparam()
1919 active_fec = link_info->active_fec_sig_mode & in bnxt_get_fecparam()
1922 fec->fec = ETHTOOL_FEC_NONE; in bnxt_get_fecparam()
1923 fec->active_fec = ETHTOOL_FEC_NONE; in bnxt_get_fecparam()
1927 fec->fec |= ETHTOOL_FEC_AUTO; in bnxt_get_fecparam()
1929 fec->fec |= ETHTOOL_FEC_BASER; in bnxt_get_fecparam()
1931 fec->fec |= ETHTOOL_FEC_RS; in bnxt_get_fecparam()
1933 fec->fec |= ETHTOOL_FEC_LLRS; in bnxt_get_fecparam()
1937 fec->active_fec |= ETHTOOL_FEC_BASER; in bnxt_get_fecparam()
1942 fec->active_fec |= ETHTOOL_FEC_RS; in bnxt_get_fecparam()
1946 fec->active_fec |= ETHTOOL_FEC_LLRS; in bnxt_get_fecparam()
1958 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_get_fec_stats()
1961 rx = bp->rx_port_stats_ext.sw_stats; in bnxt_get_fec_stats()
1962 fec_stats->corrected_bits.total = in bnxt_get_fec_stats()
1986 u32 new_cfg, fec = fecparam->fec; in bnxt_set_fecparam()
1990 link_info = &bp->link_info; in bnxt_set_fecparam()
1991 fec_cfg = link_info->fec_cfg; in bnxt_set_fecparam()
1993 return -EOPNOTSUPP; in bnxt_set_fecparam()
2004 return -EINVAL; in bnxt_set_fecparam()
2007 if (!link_info->autoneg) in bnxt_set_fecparam()
2008 return -EINVAL; in bnxt_set_fecparam()
2018 req->flags = cpu_to_le32(new_cfg | PORT_PHY_CFG_REQ_FLAGS_RESET_PHY); in bnxt_set_fecparam()
2022 mutex_lock(&bp->link_lock); in bnxt_set_fecparam()
2024 mutex_unlock(&bp->link_lock); in bnxt_set_fecparam()
2033 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_pauseparam()
2037 epause->autoneg = !!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL); in bnxt_get_pauseparam()
2038 epause->rx_pause = !!(link_info->req_flow_ctrl & BNXT_LINK_PAUSE_RX); in bnxt_get_pauseparam()
2039 epause->tx_pause = !!(link_info->req_flow_ctrl & BNXT_LINK_PAUSE_TX); in bnxt_get_pauseparam()
2048 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_pause_stats()
2051 rx = bp->port_stats.sw_stats; in bnxt_get_pause_stats()
2052 tx = bp->port_stats.sw_stats + BNXT_TX_PORT_STATS_BYTE_OFFSET / 8; in bnxt_get_pause_stats()
2054 epstat->rx_pause_frames = BNXT_GET_RX_PORT_STATS64(rx, rx_pause_frames); in bnxt_get_pause_stats()
2055 epstat->tx_pause_frames = BNXT_GET_TX_PORT_STATS64(tx, tx_pause_frames); in bnxt_get_pause_stats()
2063 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_set_pauseparam()
2066 return -EOPNOTSUPP; in bnxt_set_pauseparam()
2068 mutex_lock(&bp->link_lock); in bnxt_set_pauseparam()
2069 if (epause->autoneg) { in bnxt_set_pauseparam()
2070 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_set_pauseparam()
2071 rc = -EINVAL; in bnxt_set_pauseparam()
2075 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_set_pauseparam()
2076 if (bp->hwrm_spec_code >= 0x10201) in bnxt_set_pauseparam()
2077 link_info->req_flow_ctrl = in bnxt_set_pauseparam()
2083 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_set_pauseparam()
2084 link_info->force_link_chng = true; in bnxt_set_pauseparam()
2085 link_info->autoneg &= ~BNXT_AUTONEG_FLOW_CTRL; in bnxt_set_pauseparam()
2086 link_info->req_flow_ctrl = 0; in bnxt_set_pauseparam()
2088 if (epause->rx_pause) in bnxt_set_pauseparam()
2089 link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_RX; in bnxt_set_pauseparam()
2091 if (epause->tx_pause) in bnxt_set_pauseparam()
2092 link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_TX; in bnxt_set_pauseparam()
2098 mutex_unlock(&bp->link_lock); in bnxt_set_pauseparam()
2107 return bp->link_info.link_up; in bnxt_get_link()
2118 return -EOPNOTSUPP; in bnxt_hwrm_nvm_get_dev_info()
2134 netdev_info(bp->dev, "PF does not have admin privileges to flash or reset the device\n"); in bnxt_print_admin_err()
2161 return -ENOMEM; in bnxt_flash_nvram()
2164 req->dir_data_length = cpu_to_le32(data_len); in bnxt_flash_nvram()
2167 req->host_src_addr = cpu_to_le64(dma_handle); in bnxt_flash_nvram()
2171 req->dir_type = cpu_to_le16(dir_type); in bnxt_flash_nvram()
2172 req->dir_ordinal = cpu_to_le16(dir_ordinal); in bnxt_flash_nvram()
2173 req->dir_ext = cpu_to_le16(dir_ext); in bnxt_flash_nvram()
2174 req->dir_attr = cpu_to_le16(dir_attr); in bnxt_flash_nvram()
2175 req->dir_item_length = cpu_to_le32(dir_item_len); in bnxt_flash_nvram()
2178 if (rc == -EACCES) in bnxt_flash_nvram()
2194 req->embedded_proc_type = proc_type; in bnxt_hwrm_firmware_reset()
2195 req->selfrst_status = self_reset; in bnxt_hwrm_firmware_reset()
2196 req->flags = flags; in bnxt_hwrm_firmware_reset()
2202 if (rc == -EACCES) in bnxt_hwrm_firmware_reset()
2214 /* TODO: Address self-reset of APE/KONG/BONO/TANG or ungraceful reset */ in bnxt_firmware_reset()
2221 /* Self-reset ChiMP upon next PCIe reset: */ in bnxt_firmware_reset()
2227 /* Self-reset APE upon next PCIe reset: */ in bnxt_firmware_reset()
2239 return -EINVAL; in bnxt_firmware_reset()
2250 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET) in bnxt_firmware_reset_chip()
2306 return -EINVAL; in bnxt_flash_firmware()
2311 return -EINVAL; in bnxt_flash_firmware()
2313 if (header->signature != cpu_to_le32(BNXT_FIRMWARE_BIN_SIGNATURE)) { in bnxt_flash_firmware()
2314 netdev_err(dev, "Invalid firmware signature: %08X\n", in bnxt_flash_firmware()
2315 le32_to_cpu(header->signature)); in bnxt_flash_firmware()
2316 return -EINVAL; in bnxt_flash_firmware()
2318 if (header->code_type != code_type) { in bnxt_flash_firmware()
2320 code_type, header->code_type); in bnxt_flash_firmware()
2321 return -EINVAL; in bnxt_flash_firmware()
2323 if (header->device != DEVICE_CUMULUS_FAMILY) { in bnxt_flash_firmware()
2325 DEVICE_CUMULUS_FAMILY, header->device); in bnxt_flash_firmware()
2326 return -EINVAL; in bnxt_flash_firmware()
2329 stored_crc = le32_to_cpu(*(__le32 *)(fw_data + fw_size - in bnxt_flash_firmware()
2331 calculated_crc = ~crc32(~0, fw_data, fw_size - sizeof(stored_crc)); in bnxt_flash_firmware()
2336 return -EINVAL; in bnxt_flash_firmware()
2359 return -EINVAL; in bnxt_flash_microcode()
2361 trailer = (struct bnxt_ucode_trailer *)(fw_data + (fw_size - in bnxt_flash_microcode()
2363 if (trailer->sig != cpu_to_le32(BNXT_UCODE_TRAILER_SIGNATURE)) { in bnxt_flash_microcode()
2364 netdev_err(dev, "Invalid microcode trailer signature: %08X\n", in bnxt_flash_microcode()
2365 le32_to_cpu(trailer->sig)); in bnxt_flash_microcode()
2366 return -EINVAL; in bnxt_flash_microcode()
2368 if (le16_to_cpu(trailer->dir_type) != dir_type) { in bnxt_flash_microcode()
2370 dir_type, le16_to_cpu(trailer->dir_type)); in bnxt_flash_microcode()
2371 return -EINVAL; in bnxt_flash_microcode()
2373 if (le16_to_cpu(trailer->trailer_length) < in bnxt_flash_microcode()
2376 le16_to_cpu(trailer->trailer_length)); in bnxt_flash_microcode()
2377 return -EINVAL; in bnxt_flash_microcode()
2381 stored_crc = le32_to_cpu(*(__le32 *)(fw_data + fw_size - in bnxt_flash_microcode()
2383 calculated_crc = ~crc32(~0, fw_data, fw_size - sizeof(stored_crc)); in bnxt_flash_microcode()
2389 return -EINVAL; in bnxt_flash_microcode()
2446 rc = request_firmware(&fw, filename, &dev->dev); in bnxt_flash_firmware_from_file()
2453 rc = bnxt_flash_firmware(dev, dir_type, fw->data, fw->size); in bnxt_flash_firmware_from_file()
2455 rc = bnxt_flash_microcode(dev, dir_type, fw->data, fw->size); in bnxt_flash_firmware_from_file()
2458 0, 0, 0, fw->data, fw->size); in bnxt_flash_firmware_from_file()
2491 modify_len = roundup_pow_of_two(fw->size); in bnxt_flash_package_from_fw_obj()
2502 return -ENOMEM; in bnxt_flash_package_from_fw_obj()
2515 modify->host_src_addr = cpu_to_le64(dma_handle); in bnxt_flash_package_from_fw_obj()
2520 install->install_type = cpu_to_le32(install_type); in bnxt_flash_package_from_fw_obj()
2533 if (fw->size > item_len) { in bnxt_flash_package_from_fw_obj()
2535 (unsigned long)fw->size); in bnxt_flash_package_from_fw_obj()
2536 rc = -EFBIG; in bnxt_flash_package_from_fw_obj()
2540 modify->dir_idx = cpu_to_le16(index); in bnxt_flash_package_from_fw_obj()
2542 if (fw->size > modify_len) in bnxt_flash_package_from_fw_obj()
2543 modify->flags = BNXT_NVM_MORE_FLAG; in bnxt_flash_package_from_fw_obj()
2544 while (copied < fw->size) { in bnxt_flash_package_from_fw_obj()
2545 u32 balance = fw->size - copied; in bnxt_flash_package_from_fw_obj()
2550 modify->flags |= BNXT_NVM_LAST_FLAG; in bnxt_flash_package_from_fw_obj()
2552 memcpy(kmem, fw->data + copied, len); in bnxt_flash_package_from_fw_obj()
2553 modify->len = cpu_to_le32(len); in bnxt_flash_package_from_fw_obj()
2554 modify->offset = cpu_to_le32(copied); in bnxt_flash_package_from_fw_obj()
2570 if (rc && ((struct hwrm_err_output *)resp)->cmd_err == in bnxt_flash_package_from_fw_obj()
2572 install->flags = in bnxt_flash_package_from_fw_obj()
2577 if (rc && ((struct hwrm_err_output *)resp)->cmd_err == in bnxt_flash_package_from_fw_obj()
2583 install->flags = 0; in bnxt_flash_package_from_fw_obj()
2584 rc = bnxt_flash_nvram(bp->dev, in bnxt_flash_package_from_fw_obj()
2589 netdev_err(dev, "HWRM_NVM_INSTALL_UPDATE failure rc :%x\n", rc); in bnxt_flash_package_from_fw_obj()
2592 netdev_err(dev, "HWRM_NVM_INSTALL_UPDATE failure rc :%x\n", rc); in bnxt_flash_package_from_fw_obj()
2600 if (resp->result) { in bnxt_flash_package_from_fw_obj()
2602 (s8)resp->result, (int)resp->problem_item); in bnxt_flash_package_from_fw_obj()
2603 rc = -ENOPKG; in bnxt_flash_package_from_fw_obj()
2605 if (rc == -EACCES) in bnxt_flash_package_from_fw_obj()
2616 rc = request_firmware(&fw, filename, &dev->dev); in bnxt_flash_package_from_file()
2635 return -EINVAL; in bnxt_flash_device()
2638 if (flash->region == ETHTOOL_FLASH_ALL_REGIONS || in bnxt_flash_device()
2639 flash->region > 0xffff) in bnxt_flash_device()
2640 return bnxt_flash_package_from_file(dev, flash->data, in bnxt_flash_device()
2641 flash->region); in bnxt_flash_device()
2643 return bnxt_flash_firmware_from_file(dev, flash->region, flash->data); in bnxt_flash_device()
2660 *entries = le32_to_cpu(output->entries); in nvm_get_dir_info()
2661 *length = le32_to_cpu(output->entry_length); in nvm_get_dir_info()
2674 /* The -1 return value allows the entire 32-bit range of offsets to be in bnxt_get_eeprom_len()
2675 * passed via the ethtool command-line utility. in bnxt_get_eeprom_len()
2677 return -1; in bnxt_get_eeprom_len()
2696 return -EIO; in bnxt_get_nvram_directory()
2700 return -EINVAL; in bnxt_get_nvram_directory()
2704 len -= 2; in bnxt_get_nvram_directory()
2715 return -ENOMEM; in bnxt_get_nvram_directory()
2717 req->host_dest_addr = cpu_to_le64(dma_handle); in bnxt_get_nvram_directory()
2737 return -EINVAL; in bnxt_get_nvram_item()
2746 return -ENOMEM; in bnxt_get_nvram_item()
2749 req->host_dest_addr = cpu_to_le64(dma_handle); in bnxt_get_nvram_item()
2750 req->dir_idx = cpu_to_le16(index); in bnxt_get_nvram_item()
2751 req->offset = cpu_to_le32(offset); in bnxt_get_nvram_item()
2752 req->len = cpu_to_le32(length); in bnxt_get_nvram_item()
2775 req->enables = 0; in bnxt_find_nvram_item()
2776 req->dir_idx = 0; in bnxt_find_nvram_item()
2777 req->dir_type = cpu_to_le16(type); in bnxt_find_nvram_item()
2778 req->dir_ordinal = cpu_to_le16(ordinal); in bnxt_find_nvram_item()
2779 req->dir_ext = cpu_to_le16(ext); in bnxt_find_nvram_item()
2780 req->opt_ordinal = NVM_FIND_DIR_ENTRY_REQ_OPT_ORDINAL_EQ; in bnxt_find_nvram_item()
2785 *index = le16_to_cpu(output->dir_idx); in bnxt_find_nvram_item()
2787 *item_length = le32_to_cpu(output->dir_item_length); in bnxt_find_nvram_item()
2789 *data_length = le32_to_cpu(output->dir_data_length); in bnxt_find_nvram_item()
2804 /* null-terminate the log data (removing last '\n'): */ in bnxt_parse_pkglog()
2805 data[datalen - 1] = 0; in bnxt_parse_pkglog()
2844 dev_err(&bp->pdev->dev, "Unable to allocate memory for pkg version, length = %u\n", in bnxt_get_pkgver()
2855 len = strlen(bp->fw_ver_str); in bnxt_get_pkgver()
2856 snprintf(bp->fw_ver_str + len, FW_VER_STR_LEN - len - 1, in bnxt_get_pkgver()
2870 if (eeprom->offset == 0) /* special offset value to get directory */ in bnxt_get_eeprom()
2871 return bnxt_get_nvram_directory(dev, eeprom->len, data); in bnxt_get_eeprom()
2873 index = eeprom->offset >> 24; in bnxt_get_eeprom()
2874 offset = eeprom->offset & 0xffffff; in bnxt_get_eeprom()
2878 return -EINVAL; in bnxt_get_eeprom()
2881 return bnxt_get_nvram_item(dev, index - 1, offset, eeprom->len, data); in bnxt_get_eeprom()
2894 req->dir_idx = cpu_to_le16(index); in bnxt_erase_nvram_directory()
2908 return -EINVAL; in bnxt_set_eeprom()
2911 type = eeprom->magic >> 16; in bnxt_set_eeprom()
2914 index = eeprom->magic & 0xff; in bnxt_set_eeprom()
2915 dir_op = eeprom->magic >> 8; in bnxt_set_eeprom()
2917 return -EINVAL; in bnxt_set_eeprom()
2920 if (eeprom->offset != ~eeprom->magic) in bnxt_set_eeprom()
2921 return -EINVAL; in bnxt_set_eeprom()
2922 return bnxt_erase_nvram_directory(dev, index - 1); in bnxt_set_eeprom()
2924 return -EINVAL; in bnxt_set_eeprom()
2928 /* Create or re-write an NVM item: */ in bnxt_set_eeprom()
2930 return -EOPNOTSUPP; in bnxt_set_eeprom()
2931 ext = eeprom->magic & 0xffff; in bnxt_set_eeprom()
2932 ordinal = eeprom->offset >> 16; in bnxt_set_eeprom()
2933 attr = eeprom->offset & 0xffff; in bnxt_set_eeprom()
2936 eeprom->len); in bnxt_set_eeprom()
2942 struct ethtool_eee *eee = &bp->eee; in bnxt_set_eee()
2943 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_set_eee()
2948 return -EOPNOTSUPP; in bnxt_set_eee()
2950 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_set_eee()
2951 return -EOPNOTSUPP; in bnxt_set_eee()
2953 mutex_lock(&bp->link_lock); in bnxt_set_eee()
2954 advertising = _bnxt_fw_to_ethtool_adv_spds(link_info->advertising, 0); in bnxt_set_eee()
2955 if (!edata->eee_enabled) in bnxt_set_eee()
2958 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_set_eee()
2960 rc = -EINVAL; in bnxt_set_eee()
2963 if (edata->tx_lpi_enabled) { in bnxt_set_eee()
2964 if (bp->lpi_tmr_hi && (edata->tx_lpi_timer > bp->lpi_tmr_hi || in bnxt_set_eee()
2965 edata->tx_lpi_timer < bp->lpi_tmr_lo)) { in bnxt_set_eee()
2967 bp->lpi_tmr_lo, bp->lpi_tmr_hi); in bnxt_set_eee()
2968 rc = -EINVAL; in bnxt_set_eee()
2970 } else if (!bp->lpi_tmr_hi) { in bnxt_set_eee()
2971 edata->tx_lpi_timer = eee->tx_lpi_timer; in bnxt_set_eee()
2974 if (!edata->advertised) { in bnxt_set_eee()
2975 edata->advertised = advertising & eee->supported; in bnxt_set_eee()
2976 } else if (edata->advertised & ~advertising) { in bnxt_set_eee()
2977 netdev_warn(dev, "EEE advertised %x must be a subset of autoneg advertised speeds %x\n", in bnxt_set_eee()
2978 edata->advertised, advertising); in bnxt_set_eee()
2979 rc = -EINVAL; in bnxt_set_eee()
2983 eee->advertised = edata->advertised; in bnxt_set_eee()
2984 eee->tx_lpi_enabled = edata->tx_lpi_enabled; in bnxt_set_eee()
2985 eee->tx_lpi_timer = edata->tx_lpi_timer; in bnxt_set_eee()
2987 eee->eee_enabled = edata->eee_enabled; in bnxt_set_eee()
2993 mutex_unlock(&bp->link_lock); in bnxt_set_eee()
3001 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_get_eee()
3002 return -EOPNOTSUPP; in bnxt_get_eee()
3004 *edata = bp->eee; in bnxt_get_eee()
3005 if (!bp->eee.eee_enabled) { in bnxt_get_eee()
3007 * by default when it is re-enabled. in bnxt_get_eee()
3009 edata->advertised = 0; in bnxt_get_eee()
3010 edata->tx_lpi_enabled = 0; in bnxt_get_eee()
3013 if (!bp->eee.eee_active) in bnxt_get_eee()
3014 edata->lp_advertised = 0; in bnxt_get_eee()
3032 req->i2c_slave_addr = i2c_addr; in bnxt_read_sfp_module_eeprom_info()
3033 req->page_number = cpu_to_le16(page_number); in bnxt_read_sfp_module_eeprom_info()
3034 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_read_sfp_module_eeprom_info()
3039 data_length -= xfer_size; in bnxt_read_sfp_module_eeprom_info()
3040 req->page_offset = cpu_to_le16(start_addr + byte_offset); in bnxt_read_sfp_module_eeprom_info()
3041 req->data_length = xfer_size; in bnxt_read_sfp_module_eeprom_info()
3042 req->enables = cpu_to_le32(start_addr + byte_offset ? in bnxt_read_sfp_module_eeprom_info()
3046 memcpy(buf + byte_offset, output->data, xfer_size); in bnxt_read_sfp_module_eeprom_info()
3063 * if it is of type 10GBase-T in bnxt_get_module_info()
3065 if (bp->link_info.module_status > in bnxt_get_module_info()
3067 return -EOPNOTSUPP; in bnxt_get_module_info()
3070 if (bp->hwrm_spec_code < 0x10202) in bnxt_get_module_info()
3071 return -EOPNOTSUPP; in bnxt_get_module_info()
3082 modinfo->type = ETH_MODULE_SFF_8472; in bnxt_get_module_info()
3083 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in bnxt_get_module_info()
3085 modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN; in bnxt_get_module_info()
3089 modinfo->type = ETH_MODULE_SFF_8436; in bnxt_get_module_info()
3090 modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN; in bnxt_get_module_info()
3093 modinfo->type = ETH_MODULE_SFF_8636; in bnxt_get_module_info()
3094 modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN; in bnxt_get_module_info()
3097 rc = -EOPNOTSUPP; in bnxt_get_module_info()
3109 u16 start = eeprom->offset, length = eeprom->len; in bnxt_get_module_eeprom()
3112 memset(data, 0, eeprom->len); in bnxt_get_module_eeprom()
3116 if (start + eeprom->len > ETH_MODULE_SFF_8436_LEN) in bnxt_get_module_eeprom()
3117 length = ETH_MODULE_SFF_8436_LEN - start; in bnxt_get_module_eeprom()
3124 length = eeprom->len - length; in bnxt_get_module_eeprom()
3129 start -= ETH_MODULE_SFF_8436_LEN; in bnxt_get_module_eeprom()
3141 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_nway_reset()
3144 return -EOPNOTSUPP; in bnxt_nway_reset()
3146 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) in bnxt_nway_reset()
3147 return -EINVAL; in bnxt_nway_reset()
3160 struct bnxt_pf_info *pf = &bp->pf; in bnxt_set_phys_id()
3166 if (!bp->num_leds || BNXT_VF(bp)) in bnxt_set_phys_id()
3167 return -EOPNOTSUPP; in bnxt_set_phys_id()
3176 return -EINVAL; in bnxt_set_phys_id()
3182 req->port_id = cpu_to_le16(pf->port_id); in bnxt_set_phys_id()
3183 req->num_leds = bp->num_leds; in bnxt_set_phys_id()
3184 led_cfg = (struct bnxt_led_cfg *)&req->led0_id; in bnxt_set_phys_id()
3185 for (i = 0; i < bp->num_leds; i++, led_cfg++) { in bnxt_set_phys_id()
3186 req->enables |= BNXT_LED_DFLT_ENABLES(i); in bnxt_set_phys_id()
3187 led_cfg->led_id = bp->leds[i].led_id; in bnxt_set_phys_id()
3188 led_cfg->led_state = led_state; in bnxt_set_phys_id()
3189 led_cfg->led_blink_on = duration; in bnxt_set_phys_id()
3190 led_cfg->led_blink_off = duration; in bnxt_set_phys_id()
3191 led_cfg->led_group_id = bp->leds[i].led_group_id; in bnxt_set_phys_id()
3205 req->cmpl_ring = cpu_to_le16(cmpl_ring); in bnxt_hwrm_selftest_irq()
3213 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_test_irq()
3214 u16 cmpl_ring = bp->grp_info[i].cp_fw_ring_id; in bnxt_test_irq()
3233 req->enables = cpu_to_le32(PORT_MAC_CFG_REQ_ENABLES_LPBK); in bnxt_hwrm_mac_loopback()
3235 req->lpbk = PORT_MAC_CFG_REQ_LPBK_LOCAL; in bnxt_hwrm_mac_loopback()
3237 req->lpbk = PORT_MAC_CFG_REQ_LPBK_NONE; in bnxt_hwrm_mac_loopback()
3254 *force_speeds = le16_to_cpu(resp->supported_speeds_force_mode); in bnxt_query_force_speeds()
3263 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_disable_an_for_lpbk()
3268 if (!link_info->autoneg || in bnxt_disable_an_for_lpbk()
3269 (bp->phy_flags & BNXT_PHY_FL_AN_PHY_LPBK)) in bnxt_disable_an_for_lpbk()
3277 if (bp->link_info.link_up) in bnxt_disable_an_for_lpbk()
3278 fw_speed = bp->link_info.link_speed; in bnxt_disable_an_for_lpbk()
3288 req->force_link_speed = cpu_to_le16(fw_speed); in bnxt_disable_an_for_lpbk()
3289 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE | in bnxt_disable_an_for_lpbk()
3292 req->flags = 0; in bnxt_disable_an_for_lpbk()
3293 req->force_link_speed = cpu_to_le16(0); in bnxt_disable_an_for_lpbk()
3312 req->lpbk = PORT_PHY_CFG_REQ_LPBK_EXTERNAL; in bnxt_hwrm_phy_loopback()
3314 req->lpbk = PORT_PHY_CFG_REQ_LPBK_LOCAL; in bnxt_hwrm_phy_loopback()
3316 req->lpbk = PORT_PHY_CFG_REQ_LPBK_NONE; in bnxt_hwrm_phy_loopback()
3318 req->enables = cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_LPBK); in bnxt_hwrm_phy_loopback()
3327 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_rx_loopback()
3336 rxr = bnapi->rx_ring; in bnxt_rx_loopback()
3339 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_loopback()
3340 cons = rxcmp->rx_cmp_opaque; in bnxt_rx_loopback()
3341 rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_rx_loopback()
3342 data = rx_buf->data_ptr; in bnxt_rx_loopback()
3343 len = le32_to_cpu(rxcmp->rx_cmp_len_flags_type) >> RX_CMP_LEN_SHIFT; in bnxt_rx_loopback()
3345 return -EIO; in bnxt_rx_loopback()
3347 if (!ether_addr_equal(data + i, bnapi->bp->dev->dev_addr)) in bnxt_rx_loopback()
3348 return -EIO; in bnxt_rx_loopback()
3352 return -EIO; in bnxt_rx_loopback()
3361 int rc = -EIO; in bnxt_poll_loopback()
3366 raw_cons = cpr->cp_raw_cons; in bnxt_poll_loopback()
3369 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_poll_loopback()
3372 udelay(5); in bnxt_poll_loopback()
3388 cpr->cp_raw_cons = raw_cons; in bnxt_poll_loopback()
3394 struct bnxt_tx_ring_info *txr = &bp->tx_ring[0]; in bnxt_run_loopback()
3395 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[0]; in bnxt_run_loopback()
3403 cpr = &rxr->bnapi->cp_ring; in bnxt_run_loopback()
3404 if (bp->flags & BNXT_FLAG_CHIP_P5) in bnxt_run_loopback()
3405 cpr = cpr->cp_ring_arr[BNXT_RX_HDL]; in bnxt_run_loopback()
3406 pkt_size = min(bp->dev->mtu + ETH_HLEN, bp->rx_copy_thresh); in bnxt_run_loopback()
3407 skb = netdev_alloc_skb(bp->dev, pkt_size); in bnxt_run_loopback()
3409 return -ENOMEM; in bnxt_run_loopback()
3413 ether_addr_copy(&data[i], bp->dev->dev_addr); in bnxt_run_loopback()
3418 map = dma_map_single(&bp->pdev->dev, skb->data, pkt_size, in bnxt_run_loopback()
3420 if (dma_mapping_error(&bp->pdev->dev, map)) { in bnxt_run_loopback()
3422 return -EIO; in bnxt_run_loopback()
3429 bnxt_db_write(bp, &txr->tx_db, txr->tx_prod); in bnxt_run_loopback()
3432 dma_unmap_single(&bp->pdev->dev, map, pkt_size, DMA_TO_DEVICE); in bnxt_run_loopback()
3447 hwrm_req_timeout(bp, req, bp->test_info->timeout); in bnxt_run_fw_tests()
3448 req->flags = test_mask; in bnxt_run_fw_tests()
3452 *test_results = resp->test_success; in bnxt_run_fw_tests()
3458 #define BNXT_MACLPBK_TEST_IDX (bp->num_tests - BNXT_DRV_TESTS)
3473 if (!bp->num_tests || !BNXT_PF(bp)) in bnxt_self_test()
3475 memset(buf, 0, sizeof(u64) * bp->num_tests); in bnxt_self_test()
3477 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
3481 if ((etest->flags & ETH_TEST_FL_EXTERNAL_LB) && in bnxt_self_test()
3482 (bp->phy_flags & BNXT_PHY_FL_EXT_LPBK)) in bnxt_self_test()
3485 if (etest->flags & ETH_TEST_FL_OFFLINE) { in bnxt_self_test()
3486 if (bp->pf.active_vfs || !BNXT_SINGLE_PF(bp)) { in bnxt_self_test()
3487 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
3494 for (i = 0; i < bp->num_tests - BNXT_DRV_TESTS; i++) { in bnxt_self_test()
3497 if (!(bp->test_info->offline_mask & bit_val)) in bnxt_self_test()
3516 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
3520 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
3529 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
3532 etest->flags |= ETH_TEST_FL_EXTERNAL_LB_DONE; in bnxt_self_test()
3537 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
3546 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
3548 for (i = 0; i < bp->num_tests - BNXT_DRV_TESTS; i++) { in bnxt_self_test()
3553 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
3565 return -EINVAL; in bnxt_reset()
3569 return -EOPNOTSUPP; in bnxt_reset()
3572 if (pci_vfs_assigned(bp->pdev) && in bnxt_reset()
3573 !(bp->fw_cap & BNXT_FW_CAP_HOT_RESET)) { in bnxt_reset()
3576 return -EBUSY; in bnxt_reset()
3581 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_reset()
3584 if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET)) in bnxt_reset()
3589 return -EOPNOTSUPP; /* only request, fail hard */ in bnxt_reset()
3595 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_reset()
3602 return -EOPNOTSUPP; /* only request, fail hard */ in bnxt_reset()
3616 __le16 *seq_ptr = msg + info->seq_off; in bnxt_hwrm_dbg_dma_data()
3623 dma_buf = hwrm_req_dma_slice(bp, msg, info->dma_len, &dma_handle); in bnxt_hwrm_dbg_dma_data()
3626 return -ENOMEM; in bnxt_hwrm_dbg_dma_data()
3635 cmn_req->host_dest_addr = cpu_to_le64(dma_handle); in bnxt_hwrm_dbg_dma_data()
3636 cmn_req->host_buf_len = cpu_to_le32(info->dma_len); in bnxt_hwrm_dbg_dma_data()
3643 len = le16_to_cpu(*((__le16 *)(resp + info->data_len_off))); in bnxt_hwrm_dbg_dma_data()
3645 cmn_req->req_type == cpu_to_le16(HWRM_DBG_COREDUMP_LIST)) { in bnxt_hwrm_dbg_dma_data()
3646 info->segs = le16_to_cpu(*((__le16 *)(resp + in bnxt_hwrm_dbg_dma_data()
3648 if (!info->segs) { in bnxt_hwrm_dbg_dma_data()
3649 rc = -EIO; in bnxt_hwrm_dbg_dma_data()
3653 info->dest_buf_size = info->segs * in bnxt_hwrm_dbg_dma_data()
3655 info->dest_buf = kmalloc(info->dest_buf_size, in bnxt_hwrm_dbg_dma_data()
3657 if (!info->dest_buf) { in bnxt_hwrm_dbg_dma_data()
3658 rc = -ENOMEM; in bnxt_hwrm_dbg_dma_data()
3663 if (info->dest_buf) { in bnxt_hwrm_dbg_dma_data()
3664 if ((info->seg_start + off + len) <= in bnxt_hwrm_dbg_dma_data()
3665 BNXT_COREDUMP_BUF_LEN(info->buf_len)) { in bnxt_hwrm_dbg_dma_data()
3666 memcpy(info->dest_buf + off, dma_buf, len); in bnxt_hwrm_dbg_dma_data()
3668 rc = -ENOBUFS; in bnxt_hwrm_dbg_dma_data()
3673 if (cmn_req->req_type == in bnxt_hwrm_dbg_dma_data()
3675 info->dest_buf_size += len; in bnxt_hwrm_dbg_dma_data()
3677 if (!(cmn_resp->flags & HWRM_DBG_CMN_FLAGS_MORE)) in bnxt_hwrm_dbg_dma_data()
3705 coredump->data = info.dest_buf; in bnxt_hwrm_dbg_coredump_list()
3706 coredump->data_size = info.dest_buf_size; in bnxt_hwrm_dbg_coredump_list()
3707 coredump->total_segs = info.segs; in bnxt_hwrm_dbg_coredump_list()
3723 req->component_id = cpu_to_le16(component_id); in bnxt_hwrm_dbg_coredump_initiate()
3724 req->segment_id = cpu_to_le16(segment_id); in bnxt_hwrm_dbg_coredump_initiate()
3741 req->component_id = cpu_to_le16(component_id); in bnxt_hwrm_dbg_coredump_retrieve()
3742 req->segment_id = cpu_to_le16(segment_id); in bnxt_hwrm_dbg_coredump_retrieve()
3769 memcpy(seg_hdr->signature, "sEgM", 4); in bnxt_fill_coredump_seg_hdr()
3771 seg_hdr->component_id = (__force __le32)seg_rec->component_id; in bnxt_fill_coredump_seg_hdr()
3772 seg_hdr->segment_id = (__force __le32)seg_rec->segment_id; in bnxt_fill_coredump_seg_hdr()
3773 seg_hdr->low_version = seg_rec->version_low; in bnxt_fill_coredump_seg_hdr()
3774 seg_hdr->high_version = seg_rec->version_hi; in bnxt_fill_coredump_seg_hdr()
3779 seg_hdr->component_id = cpu_to_le32(2); in bnxt_fill_coredump_seg_hdr()
3780 seg_hdr->segment_id = 0; in bnxt_fill_coredump_seg_hdr()
3782 seg_hdr->function_id = cpu_to_le16(bp->pdev->devfn); in bnxt_fill_coredump_seg_hdr()
3783 seg_hdr->length = cpu_to_le32(seg_len); in bnxt_fill_coredump_seg_hdr()
3784 seg_hdr->status = cpu_to_le32(status); in bnxt_fill_coredump_seg_hdr()
3785 seg_hdr->duration = cpu_to_le32(duration); in bnxt_fill_coredump_seg_hdr()
3786 seg_hdr->data_offset = cpu_to_le32(sizeof(*seg_hdr)); in bnxt_fill_coredump_seg_hdr()
3787 seg_hdr->instance = cpu_to_le32(instance); in bnxt_fill_coredump_seg_hdr()
3801 memcpy(record->signature, "cOrE", 4); in bnxt_fill_coredump_record()
3802 record->flags = 0; in bnxt_fill_coredump_record()
3803 record->low_version = 0; in bnxt_fill_coredump_record()
3804 record->high_version = 1; in bnxt_fill_coredump_record()
3805 record->asic_state = 0; in bnxt_fill_coredump_record()
3806 strlcpy(record->system_name, utsname()->nodename, in bnxt_fill_coredump_record()
3807 sizeof(record->system_name)); in bnxt_fill_coredump_record()
3808 record->year = cpu_to_le16(tm.tm_year + 1900); in bnxt_fill_coredump_record()
3809 record->month = cpu_to_le16(tm.tm_mon + 1); in bnxt_fill_coredump_record()
3810 record->day = cpu_to_le16(tm.tm_mday); in bnxt_fill_coredump_record()
3811 record->hour = cpu_to_le16(tm.tm_hour); in bnxt_fill_coredump_record()
3812 record->minute = cpu_to_le16(tm.tm_min); in bnxt_fill_coredump_record()
3813 record->second = cpu_to_le16(tm.tm_sec); in bnxt_fill_coredump_record()
3814 record->utc_bias = cpu_to_le16(start_utc); in bnxt_fill_coredump_record()
3815 strcpy(record->commandline, "ethtool -w"); in bnxt_fill_coredump_record()
3816 record->total_segments = cpu_to_le32(total_segs); in bnxt_fill_coredump_record()
3818 sscanf(utsname()->release, "%u.%u", &os_ver_major, &os_ver_minor); in bnxt_fill_coredump_record()
3819 record->os_ver_major = cpu_to_le32(os_ver_major); in bnxt_fill_coredump_record()
3820 record->os_ver_minor = cpu_to_le32(os_ver_minor); in bnxt_fill_coredump_record()
3822 strlcpy(record->os_name, utsname()->sysname, 32); in bnxt_fill_coredump_record()
3824 record->end_year = cpu_to_le16(tm.tm_year + 1900); in bnxt_fill_coredump_record()
3825 record->end_month = cpu_to_le16(tm.tm_mon + 1); in bnxt_fill_coredump_record()
3826 record->end_day = cpu_to_le16(tm.tm_mday); in bnxt_fill_coredump_record()
3827 record->end_hour = cpu_to_le16(tm.tm_hour); in bnxt_fill_coredump_record()
3828 record->end_minute = cpu_to_le16(tm.tm_min); in bnxt_fill_coredump_record()
3829 record->end_second = cpu_to_le16(tm.tm_sec); in bnxt_fill_coredump_record()
3830 record->end_utc_bias = cpu_to_le16(sys_tz.tz_minuteswest * 60); in bnxt_fill_coredump_record()
3831 record->asic_id1 = cpu_to_le32(bp->chip_num << 16 | in bnxt_fill_coredump_record()
3832 bp->ver_resp.chip_rev << 8 | in bnxt_fill_coredump_record()
3833 bp->ver_resp.chip_metal); in bnxt_fill_coredump_record()
3834 record->asic_id2 = 0; in bnxt_fill_coredump_record()
3835 record->coredump_status = cpu_to_le32(status); in bnxt_fill_coredump_record()
3836 record->ioctl_low_version = 0; in bnxt_fill_coredump_record()
3837 record->ioctl_high_version = 0; in bnxt_fill_coredump_record()
3865 memcpy(buf + offset, &bp->ver_resp, ver_get_resp_len); in bnxt_get_coredump()
3871 netdev_err(bp->dev, "Failed to get coredump segment list\n"); in bnxt_get_coredump()
3881 u16 comp_id = le16_to_cpu(seg_record->component_id); in bnxt_get_coredump()
3882 u16 seg_id = le16_to_cpu(seg_record->segment_id); in bnxt_get_coredump()
3888 rc = -ENOBUFS; in bnxt_get_coredump()
3896 netdev_err(bp->dev, in bnxt_get_coredump()
3898 seg_record->segment_id); in bnxt_get_coredump()
3906 if (rc && rc == -ENOBUFS) in bnxt_get_coredump()
3909 netdev_err(bp->dev, in bnxt_get_coredump()
3911 seg_record->segment_id); in bnxt_get_coredump()
3915 duration = jiffies_to_msecs(end - start); in bnxt_get_coredump()
3938 if (rc == -ENOBUFS) in bnxt_get_coredump()
3939 netdev_err(bp->dev, "Firmware returned large coredump buffer\n"); in bnxt_get_coredump()
3947 if (dump->flag > BNXT_DUMP_CRASH) { in bnxt_set_dump()
3949 return -EINVAL; in bnxt_set_dump()
3952 if (!IS_ENABLED(CONFIG_TEE_BNXT_FW) && dump->flag == BNXT_DUMP_CRASH) { in bnxt_set_dump()
3954 return -EOPNOTSUPP; in bnxt_set_dump()
3957 bp->dump_flag = dump->flag; in bnxt_set_dump()
3965 if (bp->hwrm_spec_code < 0x10801) in bnxt_get_dump_flag()
3966 return -EOPNOTSUPP; in bnxt_get_dump_flag()
3968 dump->version = bp->ver_resp.hwrm_fw_maj_8b << 24 | in bnxt_get_dump_flag()
3969 bp->ver_resp.hwrm_fw_min_8b << 16 | in bnxt_get_dump_flag()
3970 bp->ver_resp.hwrm_fw_bld_8b << 8 | in bnxt_get_dump_flag()
3971 bp->ver_resp.hwrm_fw_rsvd_8b; in bnxt_get_dump_flag()
3973 dump->flag = bp->dump_flag; in bnxt_get_dump_flag()
3974 if (bp->dump_flag == BNXT_DUMP_CRASH) in bnxt_get_dump_flag()
3975 dump->len = BNXT_CRASH_DUMP_LEN; in bnxt_get_dump_flag()
3977 bnxt_get_coredump(bp, NULL, &dump->len); in bnxt_get_dump_flag()
3986 if (bp->hwrm_spec_code < 0x10801) in bnxt_get_dump_data()
3987 return -EOPNOTSUPP; in bnxt_get_dump_data()
3989 memset(buf, 0, dump->len); in bnxt_get_dump_data()
3991 dump->flag = bp->dump_flag; in bnxt_get_dump_data()
3992 if (dump->flag == BNXT_DUMP_CRASH) { in bnxt_get_dump_data()
3994 return tee_bnxt_copy_coredump(buf, 0, dump->len); in bnxt_get_dump_data()
3997 return bnxt_get_coredump(bp, buf, &dump->len); in bnxt_get_dump_data()
4009 ptp = bp->ptp_cfg; in bnxt_get_ts_info()
4010 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | in bnxt_get_ts_info()
4014 info->phc_index = -1; in bnxt_get_ts_info()
4018 info->so_timestamping |= SOF_TIMESTAMPING_TX_HARDWARE | in bnxt_get_ts_info()
4021 if (ptp->ptp_clock) in bnxt_get_ts_info()
4022 info->phc_index = ptp_clock_index(ptp->ptp_clock); in bnxt_get_ts_info()
4024 info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); in bnxt_get_ts_info()
4026 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in bnxt_get_ts_info()
4037 struct net_device *dev = bp->dev; in bnxt_ethtool_init()
4040 if (!(bp->fw_cap & BNXT_FW_CAP_PKG_VER)) in bnxt_ethtool_init()
4043 bp->num_tests = 0; in bnxt_ethtool_init()
4044 if (bp->hwrm_spec_code < 0x10704 || !BNXT_PF(bp)) in bnxt_ethtool_init()
4047 test_info = bp->test_info; in bnxt_ethtool_init()
4049 test_info = kzalloc(sizeof(*bp->test_info), GFP_KERNEL); in bnxt_ethtool_init()
4052 bp->test_info = test_info; in bnxt_ethtool_init()
4063 bp->num_tests = resp->num_tests + BNXT_DRV_TESTS; in bnxt_ethtool_init()
4064 if (bp->num_tests > BNXT_MAX_TEST) in bnxt_ethtool_init()
4065 bp->num_tests = BNXT_MAX_TEST; in bnxt_ethtool_init()
4067 test_info->offline_mask = resp->offline_tests; in bnxt_ethtool_init()
4068 test_info->timeout = le16_to_cpu(resp->test_timeout); in bnxt_ethtool_init()
4069 if (!test_info->timeout) in bnxt_ethtool_init()
4070 test_info->timeout = HWRM_CMD_TIMEOUT; in bnxt_ethtool_init()
4071 for (i = 0; i < bp->num_tests; i++) { in bnxt_ethtool_init()
4072 char *str = test_info->string[i]; in bnxt_ethtool_init()
4073 char *fw_str = resp->test0_name + i * 32; in bnxt_ethtool_init()
4085 strncat(str, " test", ETH_GSTRING_LEN - strlen(str)); in bnxt_ethtool_init()
4086 if (test_info->offline_mask & (1 << i)) in bnxt_ethtool_init()
4088 ETH_GSTRING_LEN - strlen(str)); in bnxt_ethtool_init()
4091 ETH_GSTRING_LEN - strlen(str)); in bnxt_ethtool_init()
4105 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_get_eth_phy_stats()
4108 rx = bp->rx_port_stats_ext.sw_stats; in bnxt_get_eth_phy_stats()
4109 phy_stats->SymbolErrorDuringCarrier = in bnxt_get_eth_phy_stats()
4119 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_eth_mac_stats()
4122 rx = bp->port_stats.sw_stats; in bnxt_get_eth_mac_stats()
4123 tx = bp->port_stats.sw_stats + BNXT_TX_PORT_STATS_BYTE_OFFSET / 8; in bnxt_get_eth_mac_stats()
4125 mac_stats->FramesReceivedOK = in bnxt_get_eth_mac_stats()
4127 mac_stats->FramesTransmittedOK = in bnxt_get_eth_mac_stats()
4129 mac_stats->FrameCheckSequenceErrors = in bnxt_get_eth_mac_stats()
4131 mac_stats->AlignmentErrors = in bnxt_get_eth_mac_stats()
4133 mac_stats->OutOfRangeLengthField = in bnxt_get_eth_mac_stats()
4143 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_eth_ctrl_stats()
4146 rx = bp->port_stats.sw_stats; in bnxt_get_eth_ctrl_stats()
4147 ctrl_stats->MACControlFramesReceived = in bnxt_get_eth_ctrl_stats()
4172 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_rmon_stats()
4175 rx = bp->port_stats.sw_stats; in bnxt_get_rmon_stats()
4176 tx = bp->port_stats.sw_stats + BNXT_TX_PORT_STATS_BYTE_OFFSET / 8; in bnxt_get_rmon_stats()
4178 rmon_stats->jabbers = in bnxt_get_rmon_stats()
4180 rmon_stats->oversize_pkts = in bnxt_get_rmon_stats()
4182 rmon_stats->undersize_pkts = in bnxt_get_rmon_stats()
4185 rmon_stats->hist[0] = BNXT_GET_RX_PORT_STATS64(rx, rx_64b_frames); in bnxt_get_rmon_stats()
4186 rmon_stats->hist[1] = BNXT_GET_RX_PORT_STATS64(rx, rx_65b_127b_frames); in bnxt_get_rmon_stats()
4187 rmon_stats->hist[2] = BNXT_GET_RX_PORT_STATS64(rx, rx_128b_255b_frames); in bnxt_get_rmon_stats()
4188 rmon_stats->hist[3] = BNXT_GET_RX_PORT_STATS64(rx, rx_256b_511b_frames); in bnxt_get_rmon_stats()
4189 rmon_stats->hist[4] = in bnxt_get_rmon_stats()
4191 rmon_stats->hist[5] = in bnxt_get_rmon_stats()
4193 rmon_stats->hist[6] = in bnxt_get_rmon_stats()
4195 rmon_stats->hist[7] = in bnxt_get_rmon_stats()
4197 rmon_stats->hist[8] = in bnxt_get_rmon_stats()
4199 rmon_stats->hist[9] = in bnxt_get_rmon_stats()
4202 rmon_stats->hist_tx[0] = in bnxt_get_rmon_stats()
4204 rmon_stats->hist_tx[1] = in bnxt_get_rmon_stats()
4206 rmon_stats->hist_tx[2] = in bnxt_get_rmon_stats()
4208 rmon_stats->hist_tx[3] = in bnxt_get_rmon_stats()
4210 rmon_stats->hist_tx[4] = in bnxt_get_rmon_stats()
4212 rmon_stats->hist_tx[5] = in bnxt_get_rmon_stats()
4214 rmon_stats->hist_tx[6] = in bnxt_get_rmon_stats()
4216 rmon_stats->hist_tx[7] = in bnxt_get_rmon_stats()
4218 rmon_stats->hist_tx[8] = in bnxt_get_rmon_stats()
4220 rmon_stats->hist_tx[9] = in bnxt_get_rmon_stats()
4228 kfree(bp->test_info); in bnxt_ethtool_free()
4229 bp->test_info = NULL; in bnxt_ethtool_free()