Lines Matching +full:tcs +full:- +full:offset
1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2014-2016 Broadcom Corporation
4 * Copyright (c) 2016-2017 Broadcom Limited
50 return bp->msg_enable; in bnxt_get_msglevel()
57 bp->msg_enable = value; in bnxt_set_msglevel()
71 coal->use_adaptive_rx_coalesce = bp->flags & BNXT_FLAG_DIM; in bnxt_get_coalesce()
73 hw_coal = &bp->rx_coal; in bnxt_get_coalesce()
74 mult = hw_coal->bufs_per_record; in bnxt_get_coalesce()
75 coal->rx_coalesce_usecs = hw_coal->coal_ticks; in bnxt_get_coalesce()
76 coal->rx_max_coalesced_frames = hw_coal->coal_bufs / mult; in bnxt_get_coalesce()
77 coal->rx_coalesce_usecs_irq = hw_coal->coal_ticks_irq; in bnxt_get_coalesce()
78 coal->rx_max_coalesced_frames_irq = hw_coal->coal_bufs_irq / mult; in bnxt_get_coalesce()
79 if (hw_coal->flags & in bnxt_get_coalesce()
81 kernel_coal->use_cqe_mode_rx = true; in bnxt_get_coalesce()
83 hw_coal = &bp->tx_coal; in bnxt_get_coalesce()
84 mult = hw_coal->bufs_per_record; in bnxt_get_coalesce()
85 coal->tx_coalesce_usecs = hw_coal->coal_ticks; in bnxt_get_coalesce()
86 coal->tx_max_coalesced_frames = hw_coal->coal_bufs / mult; in bnxt_get_coalesce()
87 coal->tx_coalesce_usecs_irq = hw_coal->coal_ticks_irq; in bnxt_get_coalesce()
88 coal->tx_max_coalesced_frames_irq = hw_coal->coal_bufs_irq / mult; in bnxt_get_coalesce()
89 if (hw_coal->flags & in bnxt_get_coalesce()
91 kernel_coal->use_cqe_mode_tx = true; in bnxt_get_coalesce()
93 coal->stats_block_coalesce_usecs = bp->stats_coal_ticks; in bnxt_get_coalesce()
109 if (coal->use_adaptive_rx_coalesce) { in bnxt_set_coalesce()
110 bp->flags |= BNXT_FLAG_DIM; in bnxt_set_coalesce()
112 if (bp->flags & BNXT_FLAG_DIM) { in bnxt_set_coalesce()
113 bp->flags &= ~(BNXT_FLAG_DIM); in bnxt_set_coalesce()
118 if ((kernel_coal->use_cqe_mode_rx || kernel_coal->use_cqe_mode_tx) && in bnxt_set_coalesce()
119 !(bp->coal_cap.cmpl_params & in bnxt_set_coalesce()
121 return -EOPNOTSUPP; in bnxt_set_coalesce()
123 hw_coal = &bp->rx_coal; in bnxt_set_coalesce()
124 mult = hw_coal->bufs_per_record; in bnxt_set_coalesce()
125 hw_coal->coal_ticks = coal->rx_coalesce_usecs; in bnxt_set_coalesce()
126 hw_coal->coal_bufs = coal->rx_max_coalesced_frames * mult; in bnxt_set_coalesce()
127 hw_coal->coal_ticks_irq = coal->rx_coalesce_usecs_irq; in bnxt_set_coalesce()
128 hw_coal->coal_bufs_irq = coal->rx_max_coalesced_frames_irq * mult; in bnxt_set_coalesce()
129 hw_coal->flags &= in bnxt_set_coalesce()
131 if (kernel_coal->use_cqe_mode_rx) in bnxt_set_coalesce()
132 hw_coal->flags |= in bnxt_set_coalesce()
135 hw_coal = &bp->tx_coal; in bnxt_set_coalesce()
136 mult = hw_coal->bufs_per_record; in bnxt_set_coalesce()
137 hw_coal->coal_ticks = coal->tx_coalesce_usecs; in bnxt_set_coalesce()
138 hw_coal->coal_bufs = coal->tx_max_coalesced_frames * mult; in bnxt_set_coalesce()
139 hw_coal->coal_ticks_irq = coal->tx_coalesce_usecs_irq; in bnxt_set_coalesce()
140 hw_coal->coal_bufs_irq = coal->tx_max_coalesced_frames_irq * mult; in bnxt_set_coalesce()
141 hw_coal->flags &= in bnxt_set_coalesce()
143 if (kernel_coal->use_cqe_mode_tx) in bnxt_set_coalesce()
144 hw_coal->flags |= in bnxt_set_coalesce()
147 if (bp->stats_coal_ticks != coal->stats_block_coalesce_usecs) { in bnxt_set_coalesce()
148 u32 stats_ticks = coal->stats_block_coalesce_usecs; in bnxt_set_coalesce()
156 bp->stats_coal_ticks = stats_ticks; in bnxt_set_coalesce()
157 if (bp->stats_coal_ticks) in bnxt_set_coalesce()
158 bp->current_interval = in bnxt_set_coalesce()
159 bp->stats_coal_ticks * HZ / 1000000; in bnxt_set_coalesce()
161 bp->current_interval = BNXT_TIMER_INTERVAL; in bnxt_set_coalesce()
166 if (test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_set_coalesce()
360 long offset; member
446 long offset; member
467 long offset; member
513 if (bp->max_tpa_v2) { in bnxt_get_num_tpa_ring_stats()
531 return rx * bp->rx_nr_rings + in bnxt_get_num_ring_stats()
532 tx * (bp->tx_nr_rings_xdp + bp->tx_nr_rings_per_tc) + in bnxt_get_num_ring_stats()
533 cmn * bp->cp_nr_rings; in bnxt_get_num_ring_stats()
543 if (bp->flags & BNXT_FLAG_PORT_STATS) in bnxt_get_num_stats()
546 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_get_num_stats()
547 len = min_t(int, bp->fw_rx_stats_ext_size, in bnxt_get_num_stats()
550 len = min_t(int, bp->fw_tx_stats_ext_size, in bnxt_get_num_stats()
553 if (bp->pri2cos_valid) in bnxt_get_num_stats()
568 if (!bp->num_tests) in bnxt_get_sset_count()
569 return -EOPNOTSUPP; in bnxt_get_sset_count()
570 return bp->num_tests; in bnxt_get_sset_count()
572 return -EOPNOTSUPP; in bnxt_get_sset_count()
578 return ring_num < bp->rx_nr_rings; in is_rx_ring()
585 if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) in is_tx_ring()
586 tx_base = bp->rx_nr_rings; in is_tx_ring()
588 if (ring_num >= tx_base && ring_num < (tx_base + bp->tx_nr_rings)) in is_tx_ring()
602 if (!bp->bnapi) { in bnxt_get_ethtool_stats()
608 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_ethtool_stats()
609 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_get_ethtool_stats()
610 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_get_ethtool_stats()
611 u64 *sw_stats = cpr->stats.sw_stats; in bnxt_get_ethtool_stats()
634 sw = (u64 *)&cpr->sw_stats->rx; in bnxt_get_ethtool_stats()
640 sw = (u64 *)&cpr->sw_stats->cmn; in bnxt_get_ethtool_stats()
649 prev = &bp->ring_err_stats_prev.rx_total_l4_csum_errors; in bnxt_get_ethtool_stats()
653 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_ethtool_stats()
654 u64 *port_stats = bp->port_stats.sw_stats; in bnxt_get_ethtool_stats()
657 buf[j] = *(port_stats + bnxt_port_stats_arr[i].offset); in bnxt_get_ethtool_stats()
659 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_get_ethtool_stats()
660 u64 *rx_port_stats_ext = bp->rx_port_stats_ext.sw_stats; in bnxt_get_ethtool_stats()
661 u64 *tx_port_stats_ext = bp->tx_port_stats_ext.sw_stats; in bnxt_get_ethtool_stats()
664 len = min_t(u32, bp->fw_rx_stats_ext_size, in bnxt_get_ethtool_stats()
668 bnxt_port_stats_ext_arr[i].offset); in bnxt_get_ethtool_stats()
670 len = min_t(u32, bp->fw_tx_stats_ext_size, in bnxt_get_ethtool_stats()
674 bnxt_tx_port_stats_ext_arr[i].offset); in bnxt_get_ethtool_stats()
676 if (bp->pri2cos_valid) { in bnxt_get_ethtool_stats()
679 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
685 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
691 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
697 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
713 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_strings()
734 if (bp->max_tpa_v2) in bnxt_get_strings()
764 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_strings()
770 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_get_strings()
773 len = min_t(u32, bp->fw_rx_stats_ext_size, in bnxt_get_strings()
779 len = min_t(u32, bp->fw_tx_stats_ext_size, in bnxt_get_strings()
786 if (bp->pri2cos_valid) { in bnxt_get_strings()
811 if (bp->num_tests) in bnxt_get_strings()
812 memcpy(buf, bp->test_info->string, in bnxt_get_strings()
813 bp->num_tests * ETH_GSTRING_LEN); in bnxt_get_strings()
816 netdev_err(bp->dev, "bnxt_get_strings invalid request %x\n", in bnxt_get_strings()
829 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in bnxt_get_ringparam()
830 ering->rx_max_pending = BNXT_MAX_RX_DESC_CNT_JUM_ENA; in bnxt_get_ringparam()
831 ering->rx_jumbo_max_pending = BNXT_MAX_RX_JUM_DESC_CNT; in bnxt_get_ringparam()
832 kernel_ering->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_ENABLED; in bnxt_get_ringparam()
834 ering->rx_max_pending = BNXT_MAX_RX_DESC_CNT; in bnxt_get_ringparam()
835 ering->rx_jumbo_max_pending = 0; in bnxt_get_ringparam()
836 kernel_ering->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_DISABLED; in bnxt_get_ringparam()
838 ering->tx_max_pending = BNXT_MAX_TX_DESC_CNT; in bnxt_get_ringparam()
840 ering->rx_pending = bp->rx_ring_size; in bnxt_get_ringparam()
841 ering->rx_jumbo_pending = bp->rx_agg_ring_size; in bnxt_get_ringparam()
842 ering->tx_pending = bp->tx_ring_size; in bnxt_get_ringparam()
852 if ((ering->rx_pending > BNXT_MAX_RX_DESC_CNT) || in bnxt_set_ringparam()
853 (ering->tx_pending > BNXT_MAX_TX_DESC_CNT) || in bnxt_set_ringparam()
854 (ering->tx_pending < BNXT_MIN_TX_DESC_CNT)) in bnxt_set_ringparam()
855 return -EINVAL; in bnxt_set_ringparam()
860 bp->rx_ring_size = ering->rx_pending; in bnxt_set_ringparam()
861 bp->tx_ring_size = ering->tx_pending; in bnxt_set_ringparam()
874 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_get_channels()
875 int max_rx_rings, max_tx_rings, tcs; in bnxt_get_channels() local
878 /* Get the most up-to-date max_tx_sch_inputs. */ in bnxt_get_channels()
881 max_tx_sch_inputs = hw_resc->max_tx_sch_inputs; in bnxt_get_channels()
887 tcs = bp->num_tc; in bnxt_get_channels()
888 tx_grps = max(tcs, 1); in bnxt_get_channels()
889 if (bp->tx_nr_rings_xdp) in bnxt_get_channels()
892 channel->max_combined = min_t(int, max_rx_rings, max_tx_rings); in bnxt_get_channels()
901 if (tcs > 1) in bnxt_get_channels()
902 max_tx_rings /= tcs; in bnxt_get_channels()
904 channel->max_rx = max_rx_rings; in bnxt_get_channels()
905 channel->max_tx = max_tx_rings; in bnxt_get_channels()
906 channel->max_other = 0; in bnxt_get_channels()
907 if (bp->flags & BNXT_FLAG_SHARED_RINGS) { in bnxt_get_channels()
908 channel->combined_count = bp->rx_nr_rings; in bnxt_get_channels()
910 channel->combined_count--; in bnxt_get_channels()
913 channel->rx_count = bp->rx_nr_rings; in bnxt_get_channels()
914 channel->tx_count = bp->tx_nr_rings_per_tc; in bnxt_get_channels()
923 int req_tx_rings, req_rx_rings, tcs; in bnxt_set_channels() local
929 if (channel->other_count) in bnxt_set_channels()
930 return -EINVAL; in bnxt_set_channels()
932 if (!channel->combined_count && in bnxt_set_channels()
933 (!channel->rx_count || !channel->tx_count)) in bnxt_set_channels()
934 return -EINVAL; in bnxt_set_channels()
936 if (channel->combined_count && in bnxt_set_channels()
937 (channel->rx_count || channel->tx_count)) in bnxt_set_channels()
938 return -EINVAL; in bnxt_set_channels()
940 if (BNXT_CHIP_TYPE_NITRO_A0(bp) && (channel->rx_count || in bnxt_set_channels()
941 channel->tx_count)) in bnxt_set_channels()
942 return -EINVAL; in bnxt_set_channels()
944 if (channel->combined_count) in bnxt_set_channels()
947 tcs = bp->num_tc; in bnxt_set_channels()
949 req_tx_rings = sh ? channel->combined_count : channel->tx_count; in bnxt_set_channels()
950 req_rx_rings = sh ? channel->combined_count : channel->rx_count; in bnxt_set_channels()
951 if (bp->tx_nr_rings_xdp) { in bnxt_set_channels()
954 return -EINVAL; in bnxt_set_channels()
960 bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) && in bnxt_set_channels()
963 return -EINVAL; in bnxt_set_channels()
966 rc = bnxt_check_rings(bp, req_tx_rings, req_rx_rings, sh, tcs, tx_xdp); in bnxt_set_channels()
982 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_set_channels()
983 bp->rx_nr_rings = channel->combined_count; in bnxt_set_channels()
984 bp->tx_nr_rings_per_tc = channel->combined_count; in bnxt_set_channels()
986 bp->flags &= ~BNXT_FLAG_SHARED_RINGS; in bnxt_set_channels()
987 bp->rx_nr_rings = channel->rx_count; in bnxt_set_channels()
988 bp->tx_nr_rings_per_tc = channel->tx_count; in bnxt_set_channels()
990 bp->tx_nr_rings_xdp = tx_xdp; in bnxt_set_channels()
991 bp->tx_nr_rings = bp->tx_nr_rings_per_tc + tx_xdp; in bnxt_set_channels()
992 if (tcs > 1) in bnxt_set_channels()
993 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs + tx_xdp; in bnxt_set_channels()
995 tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); in bnxt_set_channels()
996 bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) : in bnxt_set_channels()
997 tx_cp + bp->rx_nr_rings; in bnxt_set_channels()
1029 if (!fltr->flags || in bnxt_get_all_fltr_ids_rcu()
1030 test_bit(BNXT_FLTR_FW_DELETED, &fltr->state)) in bnxt_get_all_fltr_ids_rcu()
1032 ids[j++] = fltr->sw_id; in bnxt_get_all_fltr_ids_rcu()
1052 if (fltr->flags && fltr->sw_id == id) in bnxt_get_one_fltr_rcu()
1064 cmd->data = bp->ntp_fltr_count; in bnxt_grxclsrlall()
1066 count = bnxt_get_all_fltr_ids_rcu(bp, bp->l2_fltr_hash_tbl, in bnxt_grxclsrlall()
1068 cmd->rule_cnt); in bnxt_grxclsrlall()
1069 cmd->rule_cnt = bnxt_get_all_fltr_ids_rcu(bp, bp->ntp_fltr_hash_tbl, in bnxt_grxclsrlall()
1072 cmd->rule_cnt); in bnxt_grxclsrlall()
1081 (struct ethtool_rx_flow_spec *)&cmd->fs; in bnxt_grxclsrule()
1086 int rc = -EINVAL; in bnxt_grxclsrule()
1088 if (fs->location >= bp->max_fltr) in bnxt_grxclsrule()
1092 fltr_base = bnxt_get_one_fltr_rcu(bp, bp->l2_fltr_hash_tbl, in bnxt_grxclsrule()
1094 fs->location); in bnxt_grxclsrule()
1096 struct ethhdr *h_ether = &fs->h_u.ether_spec; in bnxt_grxclsrule()
1097 struct ethhdr *m_ether = &fs->m_u.ether_spec; in bnxt_grxclsrule()
1102 l2_key = &l2_fltr->l2_key; in bnxt_grxclsrule()
1103 fs->flow_type = ETHER_FLOW; in bnxt_grxclsrule()
1104 ether_addr_copy(h_ether->h_dest, l2_key->dst_mac_addr); in bnxt_grxclsrule()
1105 eth_broadcast_addr(m_ether->h_dest); in bnxt_grxclsrule()
1106 if (l2_key->vlan) { in bnxt_grxclsrule()
1107 struct ethtool_flow_ext *m_ext = &fs->m_ext; in bnxt_grxclsrule()
1108 struct ethtool_flow_ext *h_ext = &fs->h_ext; in bnxt_grxclsrule()
1110 fs->flow_type |= FLOW_EXT; in bnxt_grxclsrule()
1111 m_ext->vlan_tci = htons(0xfff); in bnxt_grxclsrule()
1112 h_ext->vlan_tci = htons(l2_key->vlan); in bnxt_grxclsrule()
1114 if (fltr_base->flags & BNXT_ACT_RING_DST) in bnxt_grxclsrule()
1115 fs->ring_cookie = fltr_base->rxq; in bnxt_grxclsrule()
1116 if (fltr_base->flags & BNXT_ACT_FUNC_DST) in bnxt_grxclsrule()
1117 fs->ring_cookie = (u64)(fltr_base->vf_idx + 1) << in bnxt_grxclsrule()
1122 fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, in bnxt_grxclsrule()
1124 fs->location); in bnxt_grxclsrule()
1131 fkeys = &fltr->fkeys; in bnxt_grxclsrule()
1132 fmasks = &fltr->fmasks; in bnxt_grxclsrule()
1133 if (fkeys->basic.n_proto == htons(ETH_P_IP)) { in bnxt_grxclsrule()
1134 if (fkeys->basic.ip_proto == IPPROTO_ICMP || in bnxt_grxclsrule()
1135 fkeys->basic.ip_proto == IPPROTO_RAW) { in bnxt_grxclsrule()
1136 fs->flow_type = IP_USER_FLOW; in bnxt_grxclsrule()
1137 fs->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; in bnxt_grxclsrule()
1138 if (fkeys->basic.ip_proto == IPPROTO_ICMP) in bnxt_grxclsrule()
1139 fs->h_u.usr_ip4_spec.proto = IPPROTO_ICMP; in bnxt_grxclsrule()
1141 fs->h_u.usr_ip4_spec.proto = IPPROTO_RAW; in bnxt_grxclsrule()
1142 fs->m_u.usr_ip4_spec.proto = BNXT_IP_PROTO_FULL_MASK; in bnxt_grxclsrule()
1143 } else if (fkeys->basic.ip_proto == IPPROTO_TCP) { in bnxt_grxclsrule()
1144 fs->flow_type = TCP_V4_FLOW; in bnxt_grxclsrule()
1145 } else if (fkeys->basic.ip_proto == IPPROTO_UDP) { in bnxt_grxclsrule()
1146 fs->flow_type = UDP_V4_FLOW; in bnxt_grxclsrule()
1151 fs->h_u.tcp_ip4_spec.ip4src = fkeys->addrs.v4addrs.src; in bnxt_grxclsrule()
1152 fs->m_u.tcp_ip4_spec.ip4src = fmasks->addrs.v4addrs.src; in bnxt_grxclsrule()
1153 fs->h_u.tcp_ip4_spec.ip4dst = fkeys->addrs.v4addrs.dst; in bnxt_grxclsrule()
1154 fs->m_u.tcp_ip4_spec.ip4dst = fmasks->addrs.v4addrs.dst; in bnxt_grxclsrule()
1155 if (fs->flow_type == TCP_V4_FLOW || in bnxt_grxclsrule()
1156 fs->flow_type == UDP_V4_FLOW) { in bnxt_grxclsrule()
1157 fs->h_u.tcp_ip4_spec.psrc = fkeys->ports.src; in bnxt_grxclsrule()
1158 fs->m_u.tcp_ip4_spec.psrc = fmasks->ports.src; in bnxt_grxclsrule()
1159 fs->h_u.tcp_ip4_spec.pdst = fkeys->ports.dst; in bnxt_grxclsrule()
1160 fs->m_u.tcp_ip4_spec.pdst = fmasks->ports.dst; in bnxt_grxclsrule()
1163 if (fkeys->basic.ip_proto == IPPROTO_ICMPV6 || in bnxt_grxclsrule()
1164 fkeys->basic.ip_proto == IPPROTO_RAW) { in bnxt_grxclsrule()
1165 fs->flow_type = IPV6_USER_FLOW; in bnxt_grxclsrule()
1166 if (fkeys->basic.ip_proto == IPPROTO_ICMPV6) in bnxt_grxclsrule()
1167 fs->h_u.usr_ip6_spec.l4_proto = IPPROTO_ICMPV6; in bnxt_grxclsrule()
1169 fs->h_u.usr_ip6_spec.l4_proto = IPPROTO_RAW; in bnxt_grxclsrule()
1170 fs->m_u.usr_ip6_spec.l4_proto = BNXT_IP_PROTO_FULL_MASK; in bnxt_grxclsrule()
1171 } else if (fkeys->basic.ip_proto == IPPROTO_TCP) { in bnxt_grxclsrule()
1172 fs->flow_type = TCP_V6_FLOW; in bnxt_grxclsrule()
1173 } else if (fkeys->basic.ip_proto == IPPROTO_UDP) { in bnxt_grxclsrule()
1174 fs->flow_type = UDP_V6_FLOW; in bnxt_grxclsrule()
1179 *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6src[0] = in bnxt_grxclsrule()
1180 fkeys->addrs.v6addrs.src; in bnxt_grxclsrule()
1181 *(struct in6_addr *)&fs->m_u.tcp_ip6_spec.ip6src[0] = in bnxt_grxclsrule()
1182 fmasks->addrs.v6addrs.src; in bnxt_grxclsrule()
1183 *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6dst[0] = in bnxt_grxclsrule()
1184 fkeys->addrs.v6addrs.dst; in bnxt_grxclsrule()
1185 *(struct in6_addr *)&fs->m_u.tcp_ip6_spec.ip6dst[0] = in bnxt_grxclsrule()
1186 fmasks->addrs.v6addrs.dst; in bnxt_grxclsrule()
1187 if (fs->flow_type == TCP_V6_FLOW || in bnxt_grxclsrule()
1188 fs->flow_type == UDP_V6_FLOW) { in bnxt_grxclsrule()
1189 fs->h_u.tcp_ip6_spec.psrc = fkeys->ports.src; in bnxt_grxclsrule()
1190 fs->m_u.tcp_ip6_spec.psrc = fmasks->ports.src; in bnxt_grxclsrule()
1191 fs->h_u.tcp_ip6_spec.pdst = fkeys->ports.dst; in bnxt_grxclsrule()
1192 fs->m_u.tcp_ip6_spec.pdst = fmasks->ports.dst; in bnxt_grxclsrule()
1196 if (fltr->base.flags & BNXT_ACT_DROP) in bnxt_grxclsrule()
1197 fs->ring_cookie = RX_CLS_FLOW_DISC; in bnxt_grxclsrule()
1199 fs->ring_cookie = fltr->base.rxq; in bnxt_grxclsrule()
1213 ctx = xa_load(&bp->dev->ethtool->rss_ctx, index); in bnxt_get_rss_ctx_from_index()
1224 vnic->rss_table_size = size + HW_HASH_KEY_SIZE; in bnxt_alloc_vnic_rss_table()
1225 vnic->rss_table = dma_alloc_coherent(&bp->pdev->dev, in bnxt_alloc_vnic_rss_table()
1226 vnic->rss_table_size, in bnxt_alloc_vnic_rss_table()
1227 &vnic->rss_table_dma_addr, in bnxt_alloc_vnic_rss_table()
1229 if (!vnic->rss_table) in bnxt_alloc_vnic_rss_table()
1230 return -ENOMEM; in bnxt_alloc_vnic_rss_table()
1232 vnic->rss_hash_key = ((void *)vnic->rss_table) + size; in bnxt_alloc_vnic_rss_table()
1233 vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + size; in bnxt_alloc_vnic_rss_table()
1240 u32 ring = ethtool_get_flow_spec_ring(fs->ring_cookie); in bnxt_add_l2_cls_rule()
1241 u8 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); in bnxt_add_l2_cls_rule()
1242 struct ethhdr *h_ether = &fs->h_u.ether_spec; in bnxt_add_l2_cls_rule()
1243 struct ethhdr *m_ether = &fs->m_u.ether_spec; in bnxt_add_l2_cls_rule()
1251 return -EOPNOTSUPP; in bnxt_add_l2_cls_rule()
1253 if (!is_broadcast_ether_addr(m_ether->h_dest)) in bnxt_add_l2_cls_rule()
1254 return -EINVAL; in bnxt_add_l2_cls_rule()
1255 ether_addr_copy(key.dst_mac_addr, h_ether->h_dest); in bnxt_add_l2_cls_rule()
1257 if (fs->flow_type & FLOW_EXT) { in bnxt_add_l2_cls_rule()
1258 struct ethtool_flow_ext *m_ext = &fs->m_ext; in bnxt_add_l2_cls_rule()
1259 struct ethtool_flow_ext *h_ext = &fs->h_ext; in bnxt_add_l2_cls_rule()
1261 if (m_ext->vlan_tci != htons(0xfff) || !h_ext->vlan_tci) in bnxt_add_l2_cls_rule()
1262 return -EINVAL; in bnxt_add_l2_cls_rule()
1263 key.vlan = ntohs(h_ext->vlan_tci); in bnxt_add_l2_cls_rule()
1269 vf--; in bnxt_add_l2_cls_rule()
1272 vnic_id = bp->vnic_info[ring + 1].fw_vnic_id; in bnxt_add_l2_cls_rule()
1278 fltr->base.fw_vnic_id = vnic_id; in bnxt_add_l2_cls_rule()
1279 fltr->base.rxq = ring; in bnxt_add_l2_cls_rule()
1280 fltr->base.vf_idx = vf; in bnxt_add_l2_cls_rule()
1285 fs->location = fltr->base.sw_id; in bnxt_add_l2_cls_rule()
1292 if (ip_mask->l4_4_bytes || ip_mask->tos || in bnxt_verify_ntuple_ip4_flow()
1293 ip_spec->ip_ver != ETH_RX_NFC_IP4 || in bnxt_verify_ntuple_ip4_flow()
1294 ip_mask->proto != BNXT_IP_PROTO_FULL_MASK || in bnxt_verify_ntuple_ip4_flow()
1295 (ip_spec->proto != IPPROTO_RAW && ip_spec->proto != IPPROTO_ICMP)) in bnxt_verify_ntuple_ip4_flow()
1303 if (ip_mask->l4_4_bytes || ip_mask->tclass || in bnxt_verify_ntuple_ip6_flow()
1304 ip_mask->l4_proto != BNXT_IP_PROTO_FULL_MASK || in bnxt_verify_ntuple_ip6_flow()
1305 (ip_spec->l4_proto != IPPROTO_RAW && in bnxt_verify_ntuple_ip6_flow()
1306 ip_spec->l4_proto != IPPROTO_ICMPV6)) in bnxt_verify_ntuple_ip6_flow()
1314 struct ethtool_rx_flow_spec *fs = &cmd->fs; in bnxt_add_ntuple_cls_rule()
1316 u32 flow_type = fs->flow_type & 0xff; in bnxt_add_ntuple_cls_rule()
1324 if (!bp->vnic_info) in bnxt_add_ntuple_cls_rule()
1325 return -EAGAIN; in bnxt_add_ntuple_cls_rule()
1327 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); in bnxt_add_ntuple_cls_rule()
1328 ring = ethtool_get_flow_spec_ring(fs->ring_cookie); in bnxt_add_ntuple_cls_rule()
1329 if ((fs->flow_type & (FLOW_MAC_EXT | FLOW_EXT)) || vf) in bnxt_add_ntuple_cls_rule()
1330 return -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1333 if (!bnxt_verify_ntuple_ip4_flow(&fs->h_u.usr_ip4_spec, in bnxt_add_ntuple_cls_rule()
1334 &fs->m_u.usr_ip4_spec)) in bnxt_add_ntuple_cls_rule()
1335 return -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1339 if (!bnxt_verify_ntuple_ip6_flow(&fs->h_u.usr_ip6_spec, in bnxt_add_ntuple_cls_rule()
1340 &fs->m_u.usr_ip6_spec)) in bnxt_add_ntuple_cls_rule()
1341 return -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1346 return -ENOMEM; in bnxt_add_ntuple_cls_rule()
1348 l2_fltr = bp->vnic_info[BNXT_VNIC_DEFAULT].l2_filters[0]; in bnxt_add_ntuple_cls_rule()
1349 atomic_inc(&l2_fltr->refcnt); in bnxt_add_ntuple_cls_rule()
1350 new_fltr->l2_fltr = l2_fltr; in bnxt_add_ntuple_cls_rule()
1351 fmasks = &new_fltr->fmasks; in bnxt_add_ntuple_cls_rule()
1352 fkeys = &new_fltr->fkeys; in bnxt_add_ntuple_cls_rule()
1354 rc = -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1357 struct ethtool_usrip4_spec *ip_spec = &fs->h_u.usr_ip4_spec; in bnxt_add_ntuple_cls_rule()
1358 struct ethtool_usrip4_spec *ip_mask = &fs->m_u.usr_ip4_spec; in bnxt_add_ntuple_cls_rule()
1360 fkeys->basic.ip_proto = ip_spec->proto; in bnxt_add_ntuple_cls_rule()
1361 fkeys->basic.n_proto = htons(ETH_P_IP); in bnxt_add_ntuple_cls_rule()
1362 fkeys->addrs.v4addrs.src = ip_spec->ip4src; in bnxt_add_ntuple_cls_rule()
1363 fmasks->addrs.v4addrs.src = ip_mask->ip4src; in bnxt_add_ntuple_cls_rule()
1364 fkeys->addrs.v4addrs.dst = ip_spec->ip4dst; in bnxt_add_ntuple_cls_rule()
1365 fmasks->addrs.v4addrs.dst = ip_mask->ip4dst; in bnxt_add_ntuple_cls_rule()
1370 struct ethtool_tcpip4_spec *ip_spec = &fs->h_u.tcp_ip4_spec; in bnxt_add_ntuple_cls_rule()
1371 struct ethtool_tcpip4_spec *ip_mask = &fs->m_u.tcp_ip4_spec; in bnxt_add_ntuple_cls_rule()
1373 fkeys->basic.ip_proto = IPPROTO_TCP; in bnxt_add_ntuple_cls_rule()
1375 fkeys->basic.ip_proto = IPPROTO_UDP; in bnxt_add_ntuple_cls_rule()
1376 fkeys->basic.n_proto = htons(ETH_P_IP); in bnxt_add_ntuple_cls_rule()
1377 fkeys->addrs.v4addrs.src = ip_spec->ip4src; in bnxt_add_ntuple_cls_rule()
1378 fmasks->addrs.v4addrs.src = ip_mask->ip4src; in bnxt_add_ntuple_cls_rule()
1379 fkeys->addrs.v4addrs.dst = ip_spec->ip4dst; in bnxt_add_ntuple_cls_rule()
1380 fmasks->addrs.v4addrs.dst = ip_mask->ip4dst; in bnxt_add_ntuple_cls_rule()
1381 fkeys->ports.src = ip_spec->psrc; in bnxt_add_ntuple_cls_rule()
1382 fmasks->ports.src = ip_mask->psrc; in bnxt_add_ntuple_cls_rule()
1383 fkeys->ports.dst = ip_spec->pdst; in bnxt_add_ntuple_cls_rule()
1384 fmasks->ports.dst = ip_mask->pdst; in bnxt_add_ntuple_cls_rule()
1388 struct ethtool_usrip6_spec *ip_spec = &fs->h_u.usr_ip6_spec; in bnxt_add_ntuple_cls_rule()
1389 struct ethtool_usrip6_spec *ip_mask = &fs->m_u.usr_ip6_spec; in bnxt_add_ntuple_cls_rule()
1391 fkeys->basic.ip_proto = ip_spec->l4_proto; in bnxt_add_ntuple_cls_rule()
1392 fkeys->basic.n_proto = htons(ETH_P_IPV6); in bnxt_add_ntuple_cls_rule()
1393 fkeys->addrs.v6addrs.src = *(struct in6_addr *)&ip_spec->ip6src; in bnxt_add_ntuple_cls_rule()
1394 fmasks->addrs.v6addrs.src = *(struct in6_addr *)&ip_mask->ip6src; in bnxt_add_ntuple_cls_rule()
1395 fkeys->addrs.v6addrs.dst = *(struct in6_addr *)&ip_spec->ip6dst; in bnxt_add_ntuple_cls_rule()
1396 fmasks->addrs.v6addrs.dst = *(struct in6_addr *)&ip_mask->ip6dst; in bnxt_add_ntuple_cls_rule()
1401 struct ethtool_tcpip6_spec *ip_spec = &fs->h_u.tcp_ip6_spec; in bnxt_add_ntuple_cls_rule()
1402 struct ethtool_tcpip6_spec *ip_mask = &fs->m_u.tcp_ip6_spec; in bnxt_add_ntuple_cls_rule()
1404 fkeys->basic.ip_proto = IPPROTO_TCP; in bnxt_add_ntuple_cls_rule()
1406 fkeys->basic.ip_proto = IPPROTO_UDP; in bnxt_add_ntuple_cls_rule()
1407 fkeys->basic.n_proto = htons(ETH_P_IPV6); in bnxt_add_ntuple_cls_rule()
1409 fkeys->addrs.v6addrs.src = *(struct in6_addr *)&ip_spec->ip6src; in bnxt_add_ntuple_cls_rule()
1410 fmasks->addrs.v6addrs.src = *(struct in6_addr *)&ip_mask->ip6src; in bnxt_add_ntuple_cls_rule()
1411 fkeys->addrs.v6addrs.dst = *(struct in6_addr *)&ip_spec->ip6dst; in bnxt_add_ntuple_cls_rule()
1412 fmasks->addrs.v6addrs.dst = *(struct in6_addr *)&ip_mask->ip6dst; in bnxt_add_ntuple_cls_rule()
1413 fkeys->ports.src = ip_spec->psrc; in bnxt_add_ntuple_cls_rule()
1414 fmasks->ports.src = ip_mask->psrc; in bnxt_add_ntuple_cls_rule()
1415 fkeys->ports.dst = ip_spec->pdst; in bnxt_add_ntuple_cls_rule()
1416 fmasks->ports.dst = ip_mask->pdst; in bnxt_add_ntuple_cls_rule()
1420 rc = -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1431 rc = -EEXIST; in bnxt_add_ntuple_cls_rule()
1436 new_fltr->base.flags = BNXT_ACT_NO_AGING; in bnxt_add_ntuple_cls_rule()
1437 if (fs->flow_type & FLOW_RSS) { in bnxt_add_ntuple_cls_rule()
1440 new_fltr->base.fw_vnic_id = 0; in bnxt_add_ntuple_cls_rule()
1441 new_fltr->base.flags |= BNXT_ACT_RSS_CTX; in bnxt_add_ntuple_cls_rule()
1442 rss_ctx = bnxt_get_rss_ctx_from_index(bp, cmd->rss_context); in bnxt_add_ntuple_cls_rule()
1444 new_fltr->base.fw_vnic_id = rss_ctx->index; in bnxt_add_ntuple_cls_rule()
1446 rc = -EINVAL; in bnxt_add_ntuple_cls_rule()
1450 if (fs->ring_cookie == RX_CLS_FLOW_DISC) in bnxt_add_ntuple_cls_rule()
1451 new_fltr->base.flags |= BNXT_ACT_DROP; in bnxt_add_ntuple_cls_rule()
1453 new_fltr->base.rxq = ring; in bnxt_add_ntuple_cls_rule()
1454 __set_bit(BNXT_FLTR_VALID, &new_fltr->base.state); in bnxt_add_ntuple_cls_rule()
1462 fs->location = new_fltr->base.sw_id; in bnxt_add_ntuple_cls_rule()
1467 atomic_dec(&l2_fltr->refcnt); in bnxt_add_ntuple_cls_rule()
1474 struct ethtool_rx_flow_spec *fs = &cmd->fs; in bnxt_srxclsrlins()
1479 if (!netif_running(bp->dev)) in bnxt_srxclsrlins()
1480 return -EAGAIN; in bnxt_srxclsrlins()
1481 if (!(bp->flags & BNXT_FLAG_RFS)) in bnxt_srxclsrlins()
1482 return -EPERM; in bnxt_srxclsrlins()
1483 if (fs->location != RX_CLS_LOC_ANY) in bnxt_srxclsrlins()
1484 return -EINVAL; in bnxt_srxclsrlins()
1486 flow_type = fs->flow_type; in bnxt_srxclsrlins()
1489 !(bp->fw_cap & BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO)) in bnxt_srxclsrlins()
1490 return -EOPNOTSUPP; in bnxt_srxclsrlins()
1492 return -EINVAL; in bnxt_srxclsrlins()
1495 if (fs->ring_cookie == RX_CLS_FLOW_DISC && flow_type != ETHER_FLOW) in bnxt_srxclsrlins()
1498 ring = ethtool_get_flow_spec_ring(fs->ring_cookie); in bnxt_srxclsrlins()
1499 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); in bnxt_srxclsrlins()
1501 return -EINVAL; in bnxt_srxclsrlins()
1502 if (BNXT_PF(bp) && vf > bp->pf.active_vfs) in bnxt_srxclsrlins()
1503 return -EINVAL; in bnxt_srxclsrlins()
1504 if (!vf && ring >= bp->rx_nr_rings) in bnxt_srxclsrlins()
1505 return -EINVAL; in bnxt_srxclsrlins()
1516 struct ethtool_rx_flow_spec *fs = &cmd->fs; in bnxt_srxclsrldel()
1519 u32 id = fs->location; in bnxt_srxclsrldel()
1522 fltr_base = bnxt_get_one_fltr_rcu(bp, bp->l2_fltr_hash_tbl, in bnxt_srxclsrldel()
1533 fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, in bnxt_srxclsrldel()
1537 return -ENOENT; in bnxt_srxclsrldel()
1541 if (!(fltr->base.flags & BNXT_ACT_NO_AGING)) { in bnxt_srxclsrldel()
1543 return -EINVAL; in bnxt_srxclsrldel()
1553 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4) in get_ethtool_ipv4_rss()
1560 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6) in get_ethtool_ipv6_rss()
1567 cmd->data = 0; in bnxt_grxfh()
1568 switch (cmd->flow_type) { in bnxt_grxfh()
1570 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4) in bnxt_grxfh()
1571 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1573 cmd->data |= get_ethtool_ipv4_rss(bp); in bnxt_grxfh()
1576 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4) in bnxt_grxfh()
1577 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1581 if (bp->rss_hash_cfg & in bnxt_grxfh()
1584 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1591 cmd->data |= get_ethtool_ipv4_rss(bp); in bnxt_grxfh()
1595 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6) in bnxt_grxfh()
1596 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1598 cmd->data |= get_ethtool_ipv6_rss(bp); in bnxt_grxfh()
1601 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6) in bnxt_grxfh()
1602 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1606 if (bp->rss_hash_cfg & in bnxt_grxfh()
1609 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1616 cmd->data |= get_ethtool_ipv6_rss(bp); in bnxt_grxfh()
1627 u32 rss_hash_cfg = bp->rss_hash_cfg; in bnxt_srxfh()
1630 if (cmd->data == RXH_4TUPLE) in bnxt_srxfh()
1632 else if (cmd->data == RXH_2TUPLE) in bnxt_srxfh()
1634 else if (!cmd->data) in bnxt_srxfh()
1637 return -EINVAL; in bnxt_srxfh()
1639 if (cmd->flow_type == TCP_V4_FLOW) { in bnxt_srxfh()
1643 } else if (cmd->flow_type == UDP_V4_FLOW) { in bnxt_srxfh()
1644 if (tuple == 4 && !(bp->rss_cap & BNXT_RSS_CAP_UDP_RSS_CAP)) in bnxt_srxfh()
1645 return -EINVAL; in bnxt_srxfh()
1649 } else if (cmd->flow_type == TCP_V6_FLOW) { in bnxt_srxfh()
1653 } else if (cmd->flow_type == UDP_V6_FLOW) { in bnxt_srxfh()
1654 if (tuple == 4 && !(bp->rss_cap & BNXT_RSS_CAP_UDP_RSS_CAP)) in bnxt_srxfh()
1655 return -EINVAL; in bnxt_srxfh()
1659 } else if (cmd->flow_type == AH_ESP_V4_FLOW) { in bnxt_srxfh()
1660 if (tuple == 4 && (!(bp->rss_cap & BNXT_RSS_CAP_AH_V4_RSS_CAP) || in bnxt_srxfh()
1661 !(bp->rss_cap & BNXT_RSS_CAP_ESP_V4_RSS_CAP))) in bnxt_srxfh()
1662 return -EINVAL; in bnxt_srxfh()
1668 } else if (cmd->flow_type == AH_ESP_V6_FLOW) { in bnxt_srxfh()
1669 if (tuple == 4 && (!(bp->rss_cap & BNXT_RSS_CAP_AH_V6_RSS_CAP) || in bnxt_srxfh()
1670 !(bp->rss_cap & BNXT_RSS_CAP_ESP_V6_RSS_CAP))) in bnxt_srxfh()
1671 return -EINVAL; in bnxt_srxfh()
1678 return -EINVAL; in bnxt_srxfh()
1681 switch (cmd->flow_type) { in bnxt_srxfh()
1709 if (bp->rss_hash_cfg == rss_hash_cfg) in bnxt_srxfh()
1712 if (bp->rss_cap & BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA) in bnxt_srxfh()
1713 bp->rss_hash_delta = bp->rss_hash_cfg ^ rss_hash_cfg; in bnxt_srxfh()
1714 bp->rss_hash_cfg = rss_hash_cfg; in bnxt_srxfh()
1715 if (netif_running(bp->dev)) { in bnxt_srxfh()
1728 switch (cmd->cmd) { in bnxt_get_rxnfc()
1730 cmd->data = bp->rx_nr_rings; in bnxt_get_rxnfc()
1734 cmd->rule_cnt = bp->ntp_fltr_count; in bnxt_get_rxnfc()
1735 cmd->data = bp->max_fltr | RX_CLS_LOC_SPECIAL; in bnxt_get_rxnfc()
1751 rc = -EOPNOTSUPP; in bnxt_get_rxnfc()
1763 switch (cmd->cmd) { in bnxt_set_rxnfc()
1777 rc = -EOPNOTSUPP; in bnxt_set_rxnfc()
1787 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_get_rxfh_indir_size()
1788 return bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) * in bnxt_get_rxfh_indir_size()
1803 u32 *indir_tbl = bp->rss_indir_tbl; in bnxt_get_rxfh()
1807 rxfh->hfunc = ETH_RSS_HASH_TOP; in bnxt_get_rxfh()
1809 if (!bp->vnic_info) in bnxt_get_rxfh()
1812 vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_get_rxfh()
1813 if (rxfh->rss_context) { in bnxt_get_rxfh()
1816 ctx = xa_load(&bp->dev->ethtool->rss_ctx, rxfh->rss_context); in bnxt_get_rxfh()
1818 return -EINVAL; in bnxt_get_rxfh()
1821 vnic = &rss_ctx->vnic; in bnxt_get_rxfh()
1824 if (rxfh->indir && indir_tbl) { in bnxt_get_rxfh()
1827 rxfh->indir[i] = indir_tbl[i]; in bnxt_get_rxfh()
1830 if (rxfh->key && vnic->rss_hash_key) in bnxt_get_rxfh()
1831 memcpy(rxfh->key, vnic->rss_hash_key, HW_HASH_KEY_SIZE); in bnxt_get_rxfh()
1840 if (rxfh->key) { in bnxt_modify_rss()
1842 memcpy(rss_ctx->vnic.rss_hash_key, rxfh->key, in bnxt_modify_rss()
1845 memcpy(bp->rss_hash_key, rxfh->key, HW_HASH_KEY_SIZE); in bnxt_modify_rss()
1846 bp->rss_hash_key_updated = true; in bnxt_modify_rss()
1849 if (rxfh->indir) { in bnxt_modify_rss()
1850 u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_modify_rss()
1851 u32 *indir_tbl = bp->rss_indir_tbl; in bnxt_modify_rss()
1856 indir_tbl[i] = rxfh->indir[i]; in bnxt_modify_rss()
1857 pad = bp->rss_indir_tbl_entries - tbl_size; in bnxt_modify_rss()
1867 if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) { in bnxt_rxfh_context_check()
1869 return -EOPNOTSUPP; in bnxt_rxfh_context_check()
1874 return -EOPNOTSUPP; in bnxt_rxfh_context_check()
1877 if (!netif_running(bp->dev)) { in bnxt_rxfh_context_check()
1879 return -EAGAIN; in bnxt_rxfh_context_check()
1899 if (bp->num_rss_ctx >= BNXT_MAX_ETH_RSS_CTX) { in bnxt_create_rxfh_context()
1902 return -EINVAL; in bnxt_create_rxfh_context()
1907 return -ENOMEM; in bnxt_create_rxfh_context()
1912 bp->num_rss_ctx++; in bnxt_create_rxfh_context()
1914 vnic = &rss_ctx->vnic; in bnxt_create_rxfh_context()
1915 vnic->rss_ctx = ctx; in bnxt_create_rxfh_context()
1916 vnic->flags |= BNXT_VNIC_RSSCTX_FLAG; in bnxt_create_rxfh_context()
1917 vnic->vnic_id = BNXT_VNIC_ID_INVALID; in bnxt_create_rxfh_context()
1924 ctx->hfunc = ETH_RSS_HASH_TOP; in bnxt_create_rxfh_context()
1925 memcpy(vnic->rss_hash_key, bp->rss_hash_key, HW_HASH_KEY_SIZE); in bnxt_create_rxfh_context()
1927 bp->rss_hash_key, HW_HASH_KEY_SIZE); in bnxt_create_rxfh_context()
1929 rc = bnxt_hwrm_vnic_alloc(bp, vnic, 0, bp->rx_nr_rings); in bnxt_create_rxfh_context()
1935 rc = bnxt_hwrm_vnic_set_tpa(bp, vnic, bp->flags & BNXT_FLAG_TPA); in bnxt_create_rxfh_context()
1948 rss_ctx->index = rxfh->rss_context; in bnxt_create_rxfh_context()
1972 return bnxt_hwrm_vnic_rss_cfg_p5(bp, &rss_ctx->vnic); in bnxt_modify_rxfh_context()
1996 if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) in bnxt_set_rxfh()
1997 return -EOPNOTSUPP; in bnxt_set_rxfh()
2001 if (netif_running(bp->dev)) { in bnxt_set_rxfh()
2013 strscpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); in bnxt_get_drvinfo()
2014 strscpy(info->fw_version, bp->fw_ver_str, sizeof(info->fw_version)); in bnxt_get_drvinfo()
2015 strscpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info)); in bnxt_get_drvinfo()
2016 info->n_stats = bnxt_get_num_stats(bp); in bnxt_get_drvinfo()
2017 info->testinfo_len = bp->num_tests; in bnxt_get_drvinfo()
2019 info->eedump_len = 0; in bnxt_get_drvinfo()
2021 info->regdump_len = 0; in bnxt_get_drvinfo()
2030 return -EOPNOTSUPP; in bnxt_get_regs_len()
2034 if (bp->fw_cap & BNXT_FW_CAP_PCIE_STATS_SUPPORTED) in bnxt_get_regs_len()
2049 regs->version = 0; in bnxt_get_regs()
2052 if (!(bp->fw_cap & BNXT_FW_CAP_PCIE_STATS_SUPPORTED)) in bnxt_get_regs()
2065 regs->version = 1; in bnxt_get_regs()
2067 req->pcie_stat_size = cpu_to_le16(sizeof(*hw_pcie_stats)); in bnxt_get_regs()
2068 req->pcie_stat_host_addr = cpu_to_le64(hw_pcie_stats_addr); in bnxt_get_regs()
2085 wol->supported = 0; in bnxt_get_wol()
2086 wol->wolopts = 0; in bnxt_get_wol()
2087 memset(&wol->sopass, 0, sizeof(wol->sopass)); in bnxt_get_wol()
2088 if (bp->flags & BNXT_FLAG_WOL_CAP) { in bnxt_get_wol()
2089 wol->supported = WAKE_MAGIC; in bnxt_get_wol()
2090 if (bp->wol) in bnxt_get_wol()
2091 wol->wolopts = WAKE_MAGIC; in bnxt_get_wol()
2099 if (wol->wolopts & ~WAKE_MAGIC) in bnxt_set_wol()
2100 return -EINVAL; in bnxt_set_wol()
2102 if (wol->wolopts & WAKE_MAGIC) { in bnxt_set_wol()
2103 if (!(bp->flags & BNXT_FLAG_WOL_CAP)) in bnxt_set_wol()
2104 return -EINVAL; in bnxt_set_wol()
2105 if (!bp->wol) { in bnxt_set_wol()
2107 return -EBUSY; in bnxt_set_wol()
2108 bp->wol = 1; in bnxt_set_wol()
2111 if (bp->wol) { in bnxt_set_wol()
2113 return -EBUSY; in bnxt_set_wol()
2114 bp->wol = 0; in bnxt_set_wol()
2209 switch (link_info->media_type) { in bnxt_get_media()
2215 if (link_info->phy_type < ARRAY_SIZE(bnxt_phy_types)) in bnxt_get_media()
2216 return bnxt_phy_types[link_info->phy_type]; in bnxt_get_media()
2367 #define BNXT_LINK_MODE_UNKNOWN -1
2377 if (link_info->phy_link_status != BNXT_LINK_LINK) in bnxt_get_link_mode()
2381 if (BNXT_AUTO_MODE(link_info->auto_mode)) { in bnxt_get_link_mode()
2382 speed = bnxt_fw_speed_idx(link_info->link_speed); in bnxt_get_link_mode()
2383 sig_mode = link_info->active_fec_sig_mode & in bnxt_get_link_mode()
2386 speed = bnxt_fw_speed_idx(link_info->req_link_speed); in bnxt_get_link_mode()
2387 sig_mode = link_info->req_signal_mode; in bnxt_get_link_mode()
2402 if (~link_info->duplex & BNXT_LINK_DUPLEX_FULL) in bnxt_get_link_mode()
2406 if (~link_info->duplex & BNXT_LINK_DUPLEX_FULL) in bnxt_get_link_mode()
2421 if (!(bp->phy_flags & BNXT_PHY_FL_NO_PAUSE)) { in bnxt_get_ethtool_modes()
2423 lk_ksettings->link_modes.supported); in bnxt_get_ethtool_modes()
2425 lk_ksettings->link_modes.supported); in bnxt_get_ethtool_modes()
2428 if (link_info->support_auto_speeds || link_info->support_auto_speeds2 || in bnxt_get_ethtool_modes()
2429 link_info->support_pam4_auto_speeds) in bnxt_get_ethtool_modes()
2431 lk_ksettings->link_modes.supported); in bnxt_get_ethtool_modes()
2433 if (~link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_get_ethtool_modes()
2436 if (link_info->auto_pause_setting & BNXT_LINK_PAUSE_RX) in bnxt_get_ethtool_modes()
2438 lk_ksettings->link_modes.advertising); in bnxt_get_ethtool_modes()
2439 if (hweight8(link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) == 1) in bnxt_get_ethtool_modes()
2441 lk_ksettings->link_modes.advertising); in bnxt_get_ethtool_modes()
2442 if (link_info->lp_pause & BNXT_LINK_PAUSE_RX) in bnxt_get_ethtool_modes()
2444 lk_ksettings->link_modes.lp_advertising); in bnxt_get_ethtool_modes()
2445 if (hweight8(link_info->lp_pause & BNXT_LINK_PAUSE_BOTH) == 1) in bnxt_get_ethtool_modes()
2447 lk_ksettings->link_modes.lp_advertising); in bnxt_get_ethtool_modes()
2458 [__BNXT_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
2465 [__BNXT_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
2475 [__BNXT_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
2578 u16 phy_flags = bp->phy_flags; in bnxt_get_all_ethtool_support_speeds()
2581 sp_nrz = link_info->support_speeds2; in bnxt_get_all_ethtool_support_speeds()
2582 sp_pam4 = link_info->support_speeds2; in bnxt_get_all_ethtool_support_speeds()
2583 sp_pam4_112 = link_info->support_speeds2; in bnxt_get_all_ethtool_support_speeds()
2585 sp_nrz = link_info->support_speeds; in bnxt_get_all_ethtool_support_speeds()
2586 sp_pam4 = link_info->support_pam4_speeds; in bnxt_get_all_ethtool_support_speeds()
2589 lk_ksettings->link_modes.supported); in bnxt_get_all_ethtool_support_speeds()
2591 lk_ksettings->link_modes.supported); in bnxt_get_all_ethtool_support_speeds()
2593 phy_flags, lk_ksettings->link_modes.supported); in bnxt_get_all_ethtool_support_speeds()
2603 u16 phy_flags = bp->phy_flags; in bnxt_get_all_ethtool_adv_speeds()
2605 sp_nrz = link_info->advertising; in bnxt_get_all_ethtool_adv_speeds()
2607 sp_pam4 = link_info->advertising; in bnxt_get_all_ethtool_adv_speeds()
2608 sp_pam4_112 = link_info->advertising; in bnxt_get_all_ethtool_adv_speeds()
2610 sp_pam4 = link_info->advertising_pam4; in bnxt_get_all_ethtool_adv_speeds()
2613 lk_ksettings->link_modes.advertising); in bnxt_get_all_ethtool_adv_speeds()
2615 lk_ksettings->link_modes.advertising); in bnxt_get_all_ethtool_adv_speeds()
2617 phy_flags, lk_ksettings->link_modes.advertising); in bnxt_get_all_ethtool_adv_speeds()
2626 u16 phy_flags = bp->phy_flags; in bnxt_get_all_ethtool_lp_speeds()
2628 bnxt_get_ethtool_speeds(link_info->lp_auto_link_speeds, media, in bnxt_get_all_ethtool_lp_speeds()
2630 lk_ksettings->link_modes.lp_advertising); in bnxt_get_all_ethtool_lp_speeds()
2631 bnxt_get_ethtool_speeds(link_info->lp_auto_pam4_link_speeds, media, in bnxt_get_all_ethtool_lp_speeds()
2633 lk_ksettings->link_modes.lp_advertising); in bnxt_get_all_ethtool_lp_speeds()
2671 adv = &link_info->advertising; in bnxt_set_ethtool_speeds()
2672 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_set_ethtool_speeds()
2673 adv_pam4 = &link_info->advertising; in bnxt_set_ethtool_speeds()
2674 adv_pam4_112 = &link_info->advertising; in bnxt_set_ethtool_speeds()
2679 adv_pam4 = &link_info->advertising_pam4; in bnxt_set_ethtool_speeds()
2705 u16 fec_cfg = link_info->fec_cfg; in bnxt_fw_to_ethtool_advertised_fec()
2709 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
2714 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
2717 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
2720 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
2726 u16 fec_cfg = link_info->fec_cfg; in bnxt_fw_to_ethtool_support_fec()
2730 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
2735 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
2738 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
2741 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
2784 struct ethtool_link_settings *base = &lk_ksettings->base; in bnxt_get_default_speeds()
2786 if (link_info->link_state == BNXT_LINK_STATE_UP) { in bnxt_get_default_speeds()
2787 base->speed = bnxt_fw_to_ethtool_speed(link_info->link_speed); in bnxt_get_default_speeds()
2788 base->duplex = DUPLEX_HALF; in bnxt_get_default_speeds()
2789 if (link_info->duplex & BNXT_LINK_DUPLEX_FULL) in bnxt_get_default_speeds()
2790 base->duplex = DUPLEX_FULL; in bnxt_get_default_speeds()
2791 lk_ksettings->lanes = link_info->active_lanes; in bnxt_get_default_speeds()
2792 } else if (!link_info->autoneg) { in bnxt_get_default_speeds()
2793 base->speed = bnxt_fw_to_ethtool_speed(link_info->req_link_speed); in bnxt_get_default_speeds()
2794 base->duplex = DUPLEX_HALF; in bnxt_get_default_speeds()
2795 if (link_info->req_duplex == BNXT_LINK_DUPLEX_FULL) in bnxt_get_default_speeds()
2796 base->duplex = DUPLEX_FULL; in bnxt_get_default_speeds()
2803 struct ethtool_link_settings *base = &lk_ksettings->base; in bnxt_get_link_ksettings()
2812 base->duplex = DUPLEX_UNKNOWN; in bnxt_get_link_ksettings()
2813 base->speed = SPEED_UNKNOWN; in bnxt_get_link_ksettings()
2814 link_info = &bp->link_info; in bnxt_get_link_ksettings()
2816 mutex_lock(&bp->link_lock); in bnxt_get_link_ksettings()
2827 if (link_info->autoneg) { in bnxt_get_link_ksettings()
2830 lk_ksettings->link_modes.advertising); in bnxt_get_link_ksettings()
2831 base->autoneg = AUTONEG_ENABLE; in bnxt_get_link_ksettings()
2833 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_get_link_ksettings()
2837 base->autoneg = AUTONEG_DISABLE; in bnxt_get_link_ksettings()
2840 base->port = PORT_NONE; in bnxt_get_link_ksettings()
2841 if (link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP) { in bnxt_get_link_ksettings()
2842 base->port = PORT_TP; in bnxt_get_link_ksettings()
2844 lk_ksettings->link_modes.supported); in bnxt_get_link_ksettings()
2846 lk_ksettings->link_modes.advertising); in bnxt_get_link_ksettings()
2849 lk_ksettings->link_modes.supported); in bnxt_get_link_ksettings()
2851 lk_ksettings->link_modes.advertising); in bnxt_get_link_ksettings()
2853 if (link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_DAC) in bnxt_get_link_ksettings()
2854 base->port = PORT_DA; in bnxt_get_link_ksettings()
2856 base->port = PORT_FIBRE; in bnxt_get_link_ksettings()
2858 base->phy_address = link_info->phy_addr; in bnxt_get_link_ksettings()
2859 mutex_unlock(&bp->link_lock); in bnxt_get_link_ksettings()
2868 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_force_link_speed()
2869 u16 support_pam4_spds = link_info->support_pam4_speeds; in bnxt_force_link_speed()
2870 u16 support_spds2 = link_info->support_speeds2; in bnxt_force_link_speed()
2871 u16 support_spds = link_info->support_speeds; in bnxt_force_link_speed()
2979 return -EINVAL; in bnxt_force_link_speed()
2984 return -EINVAL; in bnxt_force_link_speed()
2987 if (link_info->req_link_speed == fw_speed && in bnxt_force_link_speed()
2988 link_info->req_signal_mode == sig_mode && in bnxt_force_link_speed()
2989 link_info->autoneg == 0) in bnxt_force_link_speed()
2990 return -EALREADY; in bnxt_force_link_speed()
2992 link_info->req_link_speed = fw_speed; in bnxt_force_link_speed()
2993 link_info->req_signal_mode = sig_mode; in bnxt_force_link_speed()
2994 link_info->req_duplex = BNXT_LINK_DUPLEX_FULL; in bnxt_force_link_speed()
2995 link_info->autoneg = 0; in bnxt_force_link_speed()
2996 link_info->advertising = 0; in bnxt_force_link_speed()
2997 link_info->advertising_pam4 = 0; in bnxt_force_link_speed()
3027 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_set_link_ksettings()
3028 const struct ethtool_link_settings *base = &lk_ksettings->base; in bnxt_set_link_ksettings()
3034 return -EOPNOTSUPP; in bnxt_set_link_ksettings()
3036 mutex_lock(&bp->link_lock); in bnxt_set_link_ksettings()
3037 if (base->autoneg == AUTONEG_ENABLE) { in bnxt_set_link_ksettings()
3039 lk_ksettings->link_modes.advertising); in bnxt_set_link_ksettings()
3040 link_info->autoneg |= BNXT_AUTONEG_SPEED; in bnxt_set_link_ksettings()
3041 if (!link_info->advertising && !link_info->advertising_pam4) { in bnxt_set_link_ksettings()
3042 link_info->advertising = link_info->support_auto_speeds; in bnxt_set_link_ksettings()
3043 link_info->advertising_pam4 = in bnxt_set_link_ksettings()
3044 link_info->support_pam4_auto_speeds; in bnxt_set_link_ksettings()
3049 if (!(bp->phy_flags & BNXT_PHY_FL_NO_PAUSE)) in bnxt_set_link_ksettings()
3052 u8 phy_type = link_info->phy_type; in bnxt_set_link_ksettings()
3056 link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP) { in bnxt_set_link_ksettings()
3057 netdev_err(dev, "10GBase-T devices must autoneg\n"); in bnxt_set_link_ksettings()
3058 rc = -EINVAL; in bnxt_set_link_ksettings()
3061 if (base->duplex == DUPLEX_HALF) { in bnxt_set_link_ksettings()
3063 rc = -EINVAL; in bnxt_set_link_ksettings()
3066 speed = base->speed; in bnxt_set_link_ksettings()
3067 lanes = lk_ksettings->lanes; in bnxt_set_link_ksettings()
3070 if (rc == -EALREADY) in bnxt_set_link_ksettings()
3080 mutex_unlock(&bp->link_lock); in bnxt_set_link_ksettings()
3092 link_info = &bp->link_info; in bnxt_get_fecparam()
3093 fec_cfg = link_info->fec_cfg; in bnxt_get_fecparam()
3094 active_fec = link_info->active_fec_sig_mode & in bnxt_get_fecparam()
3097 fec->fec = ETHTOOL_FEC_NONE; in bnxt_get_fecparam()
3098 fec->active_fec = ETHTOOL_FEC_NONE; in bnxt_get_fecparam()
3102 fec->fec |= ETHTOOL_FEC_AUTO; in bnxt_get_fecparam()
3104 fec->fec |= ETHTOOL_FEC_BASER; in bnxt_get_fecparam()
3106 fec->fec |= ETHTOOL_FEC_RS; in bnxt_get_fecparam()
3108 fec->fec |= ETHTOOL_FEC_LLRS; in bnxt_get_fecparam()
3112 fec->active_fec |= ETHTOOL_FEC_BASER; in bnxt_get_fecparam()
3117 fec->active_fec |= ETHTOOL_FEC_RS; in bnxt_get_fecparam()
3121 fec->active_fec |= ETHTOOL_FEC_LLRS; in bnxt_get_fecparam()
3124 fec->active_fec |= ETHTOOL_FEC_OFF; in bnxt_get_fecparam()
3136 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_get_fec_stats()
3139 rx = bp->rx_port_stats_ext.sw_stats; in bnxt_get_fec_stats()
3140 fec_stats->corrected_bits.total = in bnxt_get_fec_stats()
3143 if (bp->fw_rx_stats_ext_size <= BNXT_RX_STATS_EXT_NUM_LEGACY) in bnxt_get_fec_stats()
3146 fec_stats->corrected_blocks.total = in bnxt_get_fec_stats()
3148 fec_stats->uncorrectable_blocks.total = in bnxt_get_fec_stats()
3172 u32 new_cfg, fec = fecparam->fec; in bnxt_set_fecparam()
3176 link_info = &bp->link_info; in bnxt_set_fecparam()
3177 fec_cfg = link_info->fec_cfg; in bnxt_set_fecparam()
3179 return -EOPNOTSUPP; in bnxt_set_fecparam()
3190 return -EINVAL; in bnxt_set_fecparam()
3193 if (!link_info->autoneg) in bnxt_set_fecparam()
3194 return -EINVAL; in bnxt_set_fecparam()
3204 req->flags = cpu_to_le32(new_cfg | PORT_PHY_CFG_REQ_FLAGS_RESET_PHY); in bnxt_set_fecparam()
3208 mutex_lock(&bp->link_lock); in bnxt_set_fecparam()
3210 mutex_unlock(&bp->link_lock); in bnxt_set_fecparam()
3219 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_pauseparam()
3223 epause->autoneg = !!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL); in bnxt_get_pauseparam()
3224 epause->rx_pause = !!(link_info->req_flow_ctrl & BNXT_LINK_PAUSE_RX); in bnxt_get_pauseparam()
3225 epause->tx_pause = !!(link_info->req_flow_ctrl & BNXT_LINK_PAUSE_TX); in bnxt_get_pauseparam()
3234 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_pause_stats()
3237 rx = bp->port_stats.sw_stats; in bnxt_get_pause_stats()
3238 tx = bp->port_stats.sw_stats + BNXT_TX_PORT_STATS_BYTE_OFFSET / 8; in bnxt_get_pause_stats()
3240 epstat->rx_pause_frames = BNXT_GET_RX_PORT_STATS64(rx, rx_pause_frames); in bnxt_get_pause_stats()
3241 epstat->tx_pause_frames = BNXT_GET_TX_PORT_STATS64(tx, tx_pause_frames); in bnxt_get_pause_stats()
3249 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_set_pauseparam()
3251 if (!BNXT_PHY_CFG_ABLE(bp) || (bp->phy_flags & BNXT_PHY_FL_NO_PAUSE)) in bnxt_set_pauseparam()
3252 return -EOPNOTSUPP; in bnxt_set_pauseparam()
3254 mutex_lock(&bp->link_lock); in bnxt_set_pauseparam()
3255 if (epause->autoneg) { in bnxt_set_pauseparam()
3256 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_set_pauseparam()
3257 rc = -EINVAL; in bnxt_set_pauseparam()
3261 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_set_pauseparam()
3262 link_info->req_flow_ctrl = 0; in bnxt_set_pauseparam()
3267 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_set_pauseparam()
3268 link_info->force_link_chng = true; in bnxt_set_pauseparam()
3269 link_info->autoneg &= ~BNXT_AUTONEG_FLOW_CTRL; in bnxt_set_pauseparam()
3270 link_info->req_flow_ctrl = 0; in bnxt_set_pauseparam()
3272 if (epause->rx_pause) in bnxt_set_pauseparam()
3273 link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_RX; in bnxt_set_pauseparam()
3275 if (epause->tx_pause) in bnxt_set_pauseparam()
3276 link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_TX; in bnxt_set_pauseparam()
3282 mutex_unlock(&bp->link_lock); in bnxt_set_pauseparam()
3302 return -EOPNOTSUPP; in bnxt_hwrm_nvm_get_dev_info()
3318 netdev_info(bp->dev, "PF does not have admin privileges to flash or reset the device\n"); in bnxt_print_admin_err()
3345 return -ENOMEM; in bnxt_flash_nvram()
3348 req->dir_data_length = cpu_to_le32(data_len); in bnxt_flash_nvram()
3351 req->host_src_addr = cpu_to_le64(dma_handle); in bnxt_flash_nvram()
3354 hwrm_req_timeout(bp, req, bp->hwrm_cmd_max_timeout); in bnxt_flash_nvram()
3355 req->dir_type = cpu_to_le16(dir_type); in bnxt_flash_nvram()
3356 req->dir_ordinal = cpu_to_le16(dir_ordinal); in bnxt_flash_nvram()
3357 req->dir_ext = cpu_to_le16(dir_ext); in bnxt_flash_nvram()
3358 req->dir_attr = cpu_to_le16(dir_attr); in bnxt_flash_nvram()
3359 req->dir_item_length = cpu_to_le32(dir_item_len); in bnxt_flash_nvram()
3362 if (rc == -EACCES) in bnxt_flash_nvram()
3375 netdev_warn(bp->dev, "Reset denied by firmware, it may be inhibited by remote driver"); in bnxt_hwrm_firmware_reset()
3376 return -EPERM; in bnxt_hwrm_firmware_reset()
3383 req->embedded_proc_type = proc_type; in bnxt_hwrm_firmware_reset()
3384 req->selfrst_status = self_reset; in bnxt_hwrm_firmware_reset()
3385 req->flags = flags; in bnxt_hwrm_firmware_reset()
3391 if (rc == -EACCES) in bnxt_hwrm_firmware_reset()
3403 /* TODO: Address self-reset of APE/KONG/BONO/TANG or ungraceful reset */ in bnxt_firmware_reset()
3410 /* Self-reset ChiMP upon next PCIe reset: */ in bnxt_firmware_reset()
3416 /* Self-reset APE upon next PCIe reset: */ in bnxt_firmware_reset()
3428 return -EINVAL; in bnxt_firmware_reset()
3439 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET) in bnxt_firmware_reset_chip()
3495 return -EINVAL; in bnxt_flash_firmware()
3500 return -EINVAL; in bnxt_flash_firmware()
3502 if (header->signature != cpu_to_le32(BNXT_FIRMWARE_BIN_SIGNATURE)) { in bnxt_flash_firmware()
3504 le32_to_cpu(header->signature)); in bnxt_flash_firmware()
3505 return -EINVAL; in bnxt_flash_firmware()
3507 if (header->code_type != code_type) { in bnxt_flash_firmware()
3509 code_type, header->code_type); in bnxt_flash_firmware()
3510 return -EINVAL; in bnxt_flash_firmware()
3512 if (header->device != DEVICE_CUMULUS_FAMILY) { in bnxt_flash_firmware()
3514 DEVICE_CUMULUS_FAMILY, header->device); in bnxt_flash_firmware()
3515 return -EINVAL; in bnxt_flash_firmware()
3518 stored_crc = le32_to_cpu(*(__le32 *)(fw_data + fw_size - in bnxt_flash_firmware()
3520 calculated_crc = ~crc32(~0, fw_data, fw_size - sizeof(stored_crc)); in bnxt_flash_firmware()
3525 return -EINVAL; in bnxt_flash_firmware()
3548 return -EINVAL; in bnxt_flash_microcode()
3550 trailer = (struct bnxt_ucode_trailer *)(fw_data + (fw_size - in bnxt_flash_microcode()
3552 if (trailer->sig != cpu_to_le32(BNXT_UCODE_TRAILER_SIGNATURE)) { in bnxt_flash_microcode()
3554 le32_to_cpu(trailer->sig)); in bnxt_flash_microcode()
3555 return -EINVAL; in bnxt_flash_microcode()
3557 if (le16_to_cpu(trailer->dir_type) != dir_type) { in bnxt_flash_microcode()
3559 dir_type, le16_to_cpu(trailer->dir_type)); in bnxt_flash_microcode()
3560 return -EINVAL; in bnxt_flash_microcode()
3562 if (le16_to_cpu(trailer->trailer_length) < in bnxt_flash_microcode()
3565 le16_to_cpu(trailer->trailer_length)); in bnxt_flash_microcode()
3566 return -EINVAL; in bnxt_flash_microcode()
3570 stored_crc = le32_to_cpu(*(__le32 *)(fw_data + fw_size - in bnxt_flash_microcode()
3572 calculated_crc = ~crc32(~0, fw_data, fw_size - sizeof(stored_crc)); in bnxt_flash_microcode()
3578 return -EINVAL; in bnxt_flash_microcode()
3635 rc = request_firmware(&fw, filename, &dev->dev); in bnxt_flash_firmware_from_file()
3642 rc = bnxt_flash_firmware(dev, dir_type, fw->data, fw->size); in bnxt_flash_firmware_from_file()
3644 rc = bnxt_flash_microcode(dev, dir_type, fw->data, fw->size); in bnxt_flash_firmware_from_file()
3647 0, 0, 0, fw->data, fw->size); in bnxt_flash_firmware_from_file()
3660 #define MSG_ANTI_ROLLBACK_ERR "HWRM_NVM_INSTALL_UPDATE failure due to Anti-rollback detected"
3674 return -EINVAL; in nvm_update_err_to_stderr()
3689 return -ENOPKG; in nvm_update_err_to_stderr()
3692 return -EPERM; in nvm_update_err_to_stderr()
3699 return -EOPNOTSUPP; in nvm_update_err_to_stderr()
3702 return -EIO; in nvm_update_err_to_stderr()
3753 rc = bnxt_resize_update_entry(dev, fw->size, extack); in bnxt_flash_package_from_fw_obj()
3766 modify_len = roundup_pow_of_two(fw->size); in bnxt_flash_package_from_fw_obj()
3777 return -ENOMEM; in bnxt_flash_package_from_fw_obj()
3786 hwrm_req_timeout(bp, modify, bp->hwrm_cmd_max_timeout); in bnxt_flash_package_from_fw_obj()
3787 hwrm_req_timeout(bp, install, bp->hwrm_cmd_max_timeout); in bnxt_flash_package_from_fw_obj()
3790 modify->host_src_addr = cpu_to_le64(dma_handle); in bnxt_flash_package_from_fw_obj()
3795 install->install_type = cpu_to_le32(install_type); in bnxt_flash_package_from_fw_obj()
3808 if (fw->size > item_len) { in bnxt_flash_package_from_fw_obj()
3810 rc = -EFBIG; in bnxt_flash_package_from_fw_obj()
3814 modify->dir_idx = cpu_to_le16(index); in bnxt_flash_package_from_fw_obj()
3816 if (fw->size > modify_len) in bnxt_flash_package_from_fw_obj()
3817 modify->flags = BNXT_NVM_MORE_FLAG; in bnxt_flash_package_from_fw_obj()
3818 while (copied < fw->size) { in bnxt_flash_package_from_fw_obj()
3819 u32 balance = fw->size - copied; in bnxt_flash_package_from_fw_obj()
3824 modify->flags |= BNXT_NVM_LAST_FLAG; in bnxt_flash_package_from_fw_obj()
3826 memcpy(kmem, fw->data + copied, len); in bnxt_flash_package_from_fw_obj()
3827 modify->len = cpu_to_le32(len); in bnxt_flash_package_from_fw_obj()
3828 modify->offset = cpu_to_le32(copied); in bnxt_flash_package_from_fw_obj()
3846 cmd_err = ((struct hwrm_err_output *)resp)->cmd_err; in bnxt_flash_package_from_fw_obj()
3851 rc = -EALREADY; in bnxt_flash_package_from_fw_obj()
3854 install->flags = in bnxt_flash_package_from_fw_obj()
3861 cmd_err = ((struct hwrm_err_output *)resp)->cmd_err; in bnxt_flash_package_from_fw_obj()
3868 install->flags = 0; in bnxt_flash_package_from_fw_obj()
3869 rc = bnxt_flash_nvram(bp->dev, in bnxt_flash_package_from_fw_obj()
3886 if (resp->result) { in bnxt_flash_package_from_fw_obj()
3888 (s8)resp->result, (int)resp->problem_item); in bnxt_flash_package_from_fw_obj()
3889 rc = nvm_update_err_to_stderr(dev, resp->result, extack); in bnxt_flash_package_from_fw_obj()
3891 if (rc == -EACCES) in bnxt_flash_package_from_fw_obj()
3902 rc = request_firmware(&fw, filename, &dev->dev); in bnxt_flash_package_from_file()
3921 return -EINVAL; in bnxt_flash_device()
3924 if (flash->region == ETHTOOL_FLASH_ALL_REGIONS || in bnxt_flash_device()
3925 flash->region > 0xffff) in bnxt_flash_device()
3926 return bnxt_flash_package_from_file(dev, flash->data, in bnxt_flash_device()
3927 flash->region, NULL); in bnxt_flash_device()
3929 return bnxt_flash_firmware_from_file(dev, flash->region, flash->data); in bnxt_flash_device()
3946 *entries = le32_to_cpu(output->entries); in nvm_get_dir_info()
3947 *length = le32_to_cpu(output->entry_length); in nvm_get_dir_info()
3960 /* The -1 return value allows the entire 32-bit range of offsets to be in bnxt_get_eeprom_len()
3961 * passed via the ethtool command-line utility. in bnxt_get_eeprom_len()
3963 return -1; in bnxt_get_eeprom_len()
3982 return -EIO; in bnxt_get_nvram_directory()
3986 return -EINVAL; in bnxt_get_nvram_directory()
3990 len -= 2; in bnxt_get_nvram_directory()
4001 return -ENOMEM; in bnxt_get_nvram_directory()
4003 req->host_dest_addr = cpu_to_le64(dma_handle); in bnxt_get_nvram_directory()
4013 int bnxt_get_nvram_item(struct net_device *dev, u32 index, u32 offset, in bnxt_get_nvram_item() argument
4023 return -EINVAL; in bnxt_get_nvram_item()
4032 return -ENOMEM; in bnxt_get_nvram_item()
4035 req->host_dest_addr = cpu_to_le64(dma_handle); in bnxt_get_nvram_item()
4036 req->dir_idx = cpu_to_le16(index); in bnxt_get_nvram_item()
4037 req->offset = cpu_to_le32(offset); in bnxt_get_nvram_item()
4038 req->len = cpu_to_le32(length); in bnxt_get_nvram_item()
4061 req->enables = 0; in bnxt_find_nvram_item()
4062 req->dir_idx = 0; in bnxt_find_nvram_item()
4063 req->dir_type = cpu_to_le16(type); in bnxt_find_nvram_item()
4064 req->dir_ordinal = cpu_to_le16(ordinal); in bnxt_find_nvram_item()
4065 req->dir_ext = cpu_to_le16(ext); in bnxt_find_nvram_item()
4066 req->opt_ordinal = NVM_FIND_DIR_ENTRY_REQ_OPT_ORDINAL_EQ; in bnxt_find_nvram_item()
4071 *index = le16_to_cpu(output->dir_idx); in bnxt_find_nvram_item()
4073 *item_length = le32_to_cpu(output->dir_item_length); in bnxt_find_nvram_item()
4075 *data_length = le32_to_cpu(output->dir_data_length); in bnxt_find_nvram_item()
4090 /* null-terminate the log data (removing last '\n'): */ in bnxt_parse_pkglog()
4091 data[datalen - 1] = 0; in bnxt_parse_pkglog()
4131 dev_err(&bp->pdev->dev, "Unable to allocate memory for pkg version, length = %u\n", in bnxt_get_pkginfo()
4133 return -ENOMEM; in bnxt_get_pkginfo()
4145 rc = -ENOENT; in bnxt_get_pkginfo()
4160 len = strlen(bp->fw_ver_str); in bnxt_get_pkgver()
4161 snprintf(bp->fw_ver_str + len, FW_VER_STR_LEN - len, in bnxt_get_pkgver()
4171 u32 offset; in bnxt_get_eeprom() local
4173 if (eeprom->offset == 0) /* special offset value to get directory */ in bnxt_get_eeprom()
4174 return bnxt_get_nvram_directory(dev, eeprom->len, data); in bnxt_get_eeprom()
4176 index = eeprom->offset >> 24; in bnxt_get_eeprom()
4177 offset = eeprom->offset & 0xffffff; in bnxt_get_eeprom()
4181 return -EINVAL; in bnxt_get_eeprom()
4184 return bnxt_get_nvram_item(dev, index - 1, offset, eeprom->len, data); in bnxt_get_eeprom()
4197 req->dir_idx = cpu_to_le16(index); in bnxt_erase_nvram_directory()
4211 return -EINVAL; in bnxt_set_eeprom()
4214 type = eeprom->magic >> 16; in bnxt_set_eeprom()
4217 index = eeprom->magic & 0xff; in bnxt_set_eeprom()
4218 dir_op = eeprom->magic >> 8; in bnxt_set_eeprom()
4220 return -EINVAL; in bnxt_set_eeprom()
4223 if (eeprom->offset != ~eeprom->magic) in bnxt_set_eeprom()
4224 return -EINVAL; in bnxt_set_eeprom()
4225 return bnxt_erase_nvram_directory(dev, index - 1); in bnxt_set_eeprom()
4227 return -EINVAL; in bnxt_set_eeprom()
4231 /* Create or re-write an NVM item: */ in bnxt_set_eeprom()
4233 return -EOPNOTSUPP; in bnxt_set_eeprom()
4234 ext = eeprom->magic & 0xffff; in bnxt_set_eeprom()
4235 ordinal = eeprom->offset >> 16; in bnxt_set_eeprom()
4236 attr = eeprom->offset & 0xffff; in bnxt_set_eeprom()
4239 eeprom->len); in bnxt_set_eeprom()
4247 struct ethtool_keee *eee = &bp->eee; in bnxt_set_eee()
4248 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_set_eee()
4252 return -EOPNOTSUPP; in bnxt_set_eee()
4254 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_set_eee()
4255 return -EOPNOTSUPP; in bnxt_set_eee()
4257 mutex_lock(&bp->link_lock); in bnxt_set_eee()
4258 _bnxt_fw_to_linkmode(advertising, link_info->advertising); in bnxt_set_eee()
4259 if (!edata->eee_enabled) in bnxt_set_eee()
4262 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_set_eee()
4264 rc = -EINVAL; in bnxt_set_eee()
4267 if (edata->tx_lpi_enabled) { in bnxt_set_eee()
4268 if (bp->lpi_tmr_hi && (edata->tx_lpi_timer > bp->lpi_tmr_hi || in bnxt_set_eee()
4269 edata->tx_lpi_timer < bp->lpi_tmr_lo)) { in bnxt_set_eee()
4271 bp->lpi_tmr_lo, bp->lpi_tmr_hi); in bnxt_set_eee()
4272 rc = -EINVAL; in bnxt_set_eee()
4274 } else if (!bp->lpi_tmr_hi) { in bnxt_set_eee()
4275 edata->tx_lpi_timer = eee->tx_lpi_timer; in bnxt_set_eee()
4278 if (linkmode_empty(edata->advertised)) { in bnxt_set_eee()
4279 linkmode_and(edata->advertised, advertising, eee->supported); in bnxt_set_eee()
4280 } else if (linkmode_andnot(tmp, edata->advertised, advertising)) { in bnxt_set_eee()
4282 rc = -EINVAL; in bnxt_set_eee()
4286 linkmode_copy(eee->advertised, edata->advertised); in bnxt_set_eee()
4287 eee->tx_lpi_enabled = edata->tx_lpi_enabled; in bnxt_set_eee()
4288 eee->tx_lpi_timer = edata->tx_lpi_timer; in bnxt_set_eee()
4290 eee->eee_enabled = edata->eee_enabled; in bnxt_set_eee()
4296 mutex_unlock(&bp->link_lock); in bnxt_set_eee()
4304 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_get_eee()
4305 return -EOPNOTSUPP; in bnxt_get_eee()
4307 *edata = bp->eee; in bnxt_get_eee()
4308 if (!bp->eee.eee_enabled) { in bnxt_get_eee()
4310 * by default when it is re-enabled. in bnxt_get_eee()
4312 linkmode_zero(edata->advertised); in bnxt_get_eee()
4313 edata->tx_lpi_enabled = 0; in bnxt_get_eee()
4316 if (!bp->eee.eee_active) in bnxt_get_eee()
4317 linkmode_zero(edata->lp_advertised); in bnxt_get_eee()
4336 req->i2c_slave_addr = i2c_addr; in bnxt_read_sfp_module_eeprom_info()
4337 req->page_number = cpu_to_le16(page_number); in bnxt_read_sfp_module_eeprom_info()
4338 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_read_sfp_module_eeprom_info()
4343 data_length -= xfer_size; in bnxt_read_sfp_module_eeprom_info()
4344 req->page_offset = cpu_to_le16(start_addr + byte_offset); in bnxt_read_sfp_module_eeprom_info()
4345 req->data_length = xfer_size; in bnxt_read_sfp_module_eeprom_info()
4346 req->enables = in bnxt_read_sfp_module_eeprom_info()
4355 memcpy(buf + byte_offset, output->data, xfer_size); in bnxt_read_sfp_module_eeprom_info()
4372 * if it is of type 10GBase-T in bnxt_get_module_info()
4374 if (bp->link_info.module_status > in bnxt_get_module_info()
4376 return -EOPNOTSUPP; in bnxt_get_module_info()
4379 if (bp->hwrm_spec_code < 0x10202) in bnxt_get_module_info()
4380 return -EOPNOTSUPP; in bnxt_get_module_info()
4391 modinfo->type = ETH_MODULE_SFF_8472; in bnxt_get_module_info()
4392 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in bnxt_get_module_info()
4394 modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN; in bnxt_get_module_info()
4398 modinfo->type = ETH_MODULE_SFF_8436; in bnxt_get_module_info()
4399 modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN; in bnxt_get_module_info()
4402 modinfo->type = ETH_MODULE_SFF_8636; in bnxt_get_module_info()
4403 modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN; in bnxt_get_module_info()
4406 rc = -EOPNOTSUPP; in bnxt_get_module_info()
4418 u16 start = eeprom->offset, length = eeprom->len; in bnxt_get_module_eeprom()
4421 memset(data, 0, eeprom->len); in bnxt_get_module_eeprom()
4425 if (start + eeprom->len > ETH_MODULE_SFF_8436_LEN) in bnxt_get_module_eeprom()
4426 length = ETH_MODULE_SFF_8436_LEN - start; in bnxt_get_module_eeprom()
4433 length = eeprom->len - length; in bnxt_get_module_eeprom()
4438 start -= ETH_MODULE_SFF_8436_LEN; in bnxt_get_module_eeprom()
4447 if (bp->link_info.module_status <= in bnxt_get_module_status()
4451 switch (bp->link_info.module_status) { in bnxt_get_module_status()
4465 return -EINVAL; in bnxt_get_module_status()
4479 if (bp->hwrm_spec_code < 0x10202) { in bnxt_get_module_eeprom_by_page()
4481 return -EINVAL; in bnxt_get_module_eeprom_by_page()
4484 if (page_data->bank && !(bp->phy_flags & BNXT_PHY_FL_BANK_SEL)) { in bnxt_get_module_eeprom_by_page()
4486 return -EINVAL; in bnxt_get_module_eeprom_by_page()
4489 rc = bnxt_read_sfp_module_eeprom_info(bp, page_data->i2c_address << 1, in bnxt_get_module_eeprom_by_page()
4490 page_data->page, page_data->bank, in bnxt_get_module_eeprom_by_page()
4491 page_data->offset, in bnxt_get_module_eeprom_by_page()
4492 page_data->length, in bnxt_get_module_eeprom_by_page()
4493 page_data->data); in bnxt_get_module_eeprom_by_page()
4498 return page_data->length; in bnxt_get_module_eeprom_by_page()
4506 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_nway_reset()
4509 return -EOPNOTSUPP; in bnxt_nway_reset()
4511 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) in bnxt_nway_reset()
4512 return -EINVAL; in bnxt_nway_reset()
4525 struct bnxt_pf_info *pf = &bp->pf; in bnxt_set_phys_id()
4531 if (!bp->num_leds || BNXT_VF(bp)) in bnxt_set_phys_id()
4532 return -EOPNOTSUPP; in bnxt_set_phys_id()
4541 return -EINVAL; in bnxt_set_phys_id()
4547 req->port_id = cpu_to_le16(pf->port_id); in bnxt_set_phys_id()
4548 req->num_leds = bp->num_leds; in bnxt_set_phys_id()
4549 led_cfg = (struct bnxt_led_cfg *)&req->led0_id; in bnxt_set_phys_id()
4550 for (i = 0; i < bp->num_leds; i++, led_cfg++) { in bnxt_set_phys_id()
4551 req->enables |= BNXT_LED_DFLT_ENABLES(i); in bnxt_set_phys_id()
4552 led_cfg->led_id = bp->leds[i].led_id; in bnxt_set_phys_id()
4553 led_cfg->led_state = led_state; in bnxt_set_phys_id()
4554 led_cfg->led_blink_on = duration; in bnxt_set_phys_id()
4555 led_cfg->led_blink_off = duration; in bnxt_set_phys_id()
4556 led_cfg->led_group_id = bp->leds[i].led_group_id; in bnxt_set_phys_id()
4570 req->cmpl_ring = cpu_to_le16(cmpl_ring); in bnxt_hwrm_selftest_irq()
4578 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_test_irq()
4579 u16 cmpl_ring = bp->grp_info[i].cp_fw_ring_id; in bnxt_test_irq()
4598 req->enables = cpu_to_le32(PORT_MAC_CFG_REQ_ENABLES_LPBK); in bnxt_hwrm_mac_loopback()
4600 req->lpbk = PORT_MAC_CFG_REQ_LPBK_LOCAL; in bnxt_hwrm_mac_loopback()
4602 req->lpbk = PORT_MAC_CFG_REQ_LPBK_NONE; in bnxt_hwrm_mac_loopback()
4619 *force_speeds = le16_to_cpu(resp->supported_speeds_force_mode); in bnxt_query_force_speeds()
4628 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_disable_an_for_lpbk()
4633 if (!link_info->autoneg || in bnxt_disable_an_for_lpbk()
4634 (bp->phy_flags & BNXT_PHY_FL_AN_PHY_LPBK)) in bnxt_disable_an_for_lpbk()
4643 fw_speed = bp->link_info.link_speed; in bnxt_disable_an_for_lpbk()
4653 req->force_link_speed = cpu_to_le16(fw_speed); in bnxt_disable_an_for_lpbk()
4654 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE | in bnxt_disable_an_for_lpbk()
4657 req->flags = 0; in bnxt_disable_an_for_lpbk()
4658 req->force_link_speed = cpu_to_le16(0); in bnxt_disable_an_for_lpbk()
4677 req->lpbk = PORT_PHY_CFG_REQ_LPBK_EXTERNAL; in bnxt_hwrm_phy_loopback()
4679 req->lpbk = PORT_PHY_CFG_REQ_LPBK_LOCAL; in bnxt_hwrm_phy_loopback()
4681 req->lpbk = PORT_PHY_CFG_REQ_LPBK_NONE; in bnxt_hwrm_phy_loopback()
4683 req->enables = cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_LPBK); in bnxt_hwrm_phy_loopback()
4692 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_rx_loopback()
4701 rxr = bnapi->rx_ring; in bnxt_rx_loopback()
4704 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_loopback()
4705 cons = rxcmp->rx_cmp_opaque; in bnxt_rx_loopback()
4706 rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_rx_loopback()
4707 data = rx_buf->data_ptr; in bnxt_rx_loopback()
4708 len = le32_to_cpu(rxcmp->rx_cmp_len_flags_type) >> RX_CMP_LEN_SHIFT; in bnxt_rx_loopback()
4710 return -EIO; in bnxt_rx_loopback()
4712 if (!ether_addr_equal(data + i, bnapi->bp->dev->dev_addr)) in bnxt_rx_loopback()
4713 return -EIO; in bnxt_rx_loopback()
4717 return -EIO; in bnxt_rx_loopback()
4726 int rc = -EIO; in bnxt_poll_loopback()
4731 raw_cons = cpr->cp_raw_cons; in bnxt_poll_loopback()
4734 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_poll_loopback()
4754 cpr->cp_raw_cons = raw_cons; in bnxt_poll_loopback()
4760 struct bnxt_tx_ring_info *txr = &bp->tx_ring[0]; in bnxt_run_loopback()
4761 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[0]; in bnxt_run_loopback()
4769 cpr = &rxr->bnapi->cp_ring; in bnxt_run_loopback()
4770 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_run_loopback()
4771 cpr = rxr->rx_cpr; in bnxt_run_loopback()
4772 pkt_size = min(bp->dev->mtu + ETH_HLEN, bp->rx_copy_thresh); in bnxt_run_loopback()
4773 skb = netdev_alloc_skb(bp->dev, pkt_size); in bnxt_run_loopback()
4775 return -ENOMEM; in bnxt_run_loopback()
4777 ether_addr_copy(&data[i], bp->dev->dev_addr); in bnxt_run_loopback()
4779 ether_addr_copy(&data[i], bp->dev->dev_addr); in bnxt_run_loopback()
4784 map = dma_map_single(&bp->pdev->dev, skb->data, pkt_size, in bnxt_run_loopback()
4786 if (dma_mapping_error(&bp->pdev->dev, map)) { in bnxt_run_loopback()
4788 return -EIO; in bnxt_run_loopback()
4795 bnxt_db_write(bp, &txr->tx_db, txr->tx_prod); in bnxt_run_loopback()
4798 dma_unmap_single(&bp->pdev->dev, map, pkt_size, DMA_TO_DEVICE); in bnxt_run_loopback()
4813 hwrm_req_timeout(bp, req, bp->test_info->timeout); in bnxt_run_fw_tests()
4814 req->flags = test_mask; in bnxt_run_fw_tests()
4818 *test_results = resp->test_success; in bnxt_run_fw_tests()
4824 #define BNXT_MACLPBK_TEST_IDX (bp->num_tests - BNXT_DRV_TESTS)
4839 if (!bp->num_tests || !BNXT_PF(bp)) in bnxt_self_test()
4842 if (etest->flags & ETH_TEST_FL_OFFLINE && in bnxt_self_test()
4843 bnxt_ulp_registered(bp->edev)) { in bnxt_self_test()
4844 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4849 memset(buf, 0, sizeof(u64) * bp->num_tests); in bnxt_self_test()
4851 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4855 if ((etest->flags & ETH_TEST_FL_EXTERNAL_LB) && in bnxt_self_test()
4856 (bp->phy_flags & BNXT_PHY_FL_EXT_LPBK)) in bnxt_self_test()
4859 if (etest->flags & ETH_TEST_FL_OFFLINE) { in bnxt_self_test()
4860 if (bp->pf.active_vfs || !BNXT_SINGLE_PF(bp)) { in bnxt_self_test()
4861 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4868 for (i = 0; i < bp->num_tests - BNXT_DRV_TESTS; i++) { in bnxt_self_test()
4871 if (!(bp->test_info->offline_mask & bit_val)) in bnxt_self_test()
4888 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4892 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4901 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4904 etest->flags |= ETH_TEST_FL_EXTERNAL_LB_DONE; in bnxt_self_test()
4909 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4918 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4920 for (i = 0; i < bp->num_tests - BNXT_DRV_TESTS; i++) { in bnxt_self_test()
4925 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4937 return -EINVAL; in bnxt_reset()
4941 return -EOPNOTSUPP; in bnxt_reset()
4944 if (pci_vfs_assigned(bp->pdev) && in bnxt_reset()
4945 !(bp->fw_cap & BNXT_FW_CAP_HOT_RESET)) { in bnxt_reset()
4948 return -EBUSY; in bnxt_reset()
4953 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_reset()
4956 if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET)) in bnxt_reset()
4961 return -EOPNOTSUPP; /* only request, fail hard */ in bnxt_reset()
4967 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_reset()
4974 return -EOPNOTSUPP; /* only request, fail hard */ in bnxt_reset()
4988 if (dump->flag > BNXT_DUMP_CRASH) { in bnxt_set_dump()
4990 return -EINVAL; in bnxt_set_dump()
4993 if (dump->flag == BNXT_DUMP_CRASH) { in bnxt_set_dump()
4994 if (bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_SOC_DDR && in bnxt_set_dump()
4998 return -EOPNOTSUPP; in bnxt_set_dump()
4999 } else if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR)) { in bnxt_set_dump()
5001 return -EOPNOTSUPP; in bnxt_set_dump()
5005 bp->dump_flag = dump->flag; in bnxt_set_dump()
5013 if (bp->hwrm_spec_code < 0x10801) in bnxt_get_dump_flag()
5014 return -EOPNOTSUPP; in bnxt_get_dump_flag()
5016 dump->version = bp->ver_resp.hwrm_fw_maj_8b << 24 | in bnxt_get_dump_flag()
5017 bp->ver_resp.hwrm_fw_min_8b << 16 | in bnxt_get_dump_flag()
5018 bp->ver_resp.hwrm_fw_bld_8b << 8 | in bnxt_get_dump_flag()
5019 bp->ver_resp.hwrm_fw_rsvd_8b; in bnxt_get_dump_flag()
5021 dump->flag = bp->dump_flag; in bnxt_get_dump_flag()
5022 dump->len = bnxt_get_coredump_length(bp, bp->dump_flag); in bnxt_get_dump_flag()
5031 if (bp->hwrm_spec_code < 0x10801) in bnxt_get_dump_data()
5032 return -EOPNOTSUPP; in bnxt_get_dump_data()
5034 memset(buf, 0, dump->len); in bnxt_get_dump_data()
5036 dump->flag = bp->dump_flag; in bnxt_get_dump_data()
5037 return bnxt_get_coredump(bp, dump->flag, buf, &dump->len); in bnxt_get_dump_data()
5046 ptp = bp->ptp_cfg; in bnxt_get_ts_info()
5047 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE; in bnxt_get_ts_info()
5052 info->so_timestamping |= SOF_TIMESTAMPING_TX_HARDWARE | in bnxt_get_ts_info()
5055 if (ptp->ptp_clock) in bnxt_get_ts_info()
5056 info->phc_index = ptp_clock_index(ptp->ptp_clock); in bnxt_get_ts_info()
5058 info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); in bnxt_get_ts_info()
5060 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in bnxt_get_ts_info()
5064 if (bp->fw_cap & BNXT_FW_CAP_RX_ALL_PKT_TS) in bnxt_get_ts_info()
5065 info->rx_filters |= (1 << HWTSTAMP_FILTER_ALL); in bnxt_get_ts_info()
5074 struct net_device *dev = bp->dev; in bnxt_ethtool_init()
5077 if (!(bp->fw_cap & BNXT_FW_CAP_PKG_VER)) in bnxt_ethtool_init()
5080 bp->num_tests = 0; in bnxt_ethtool_init()
5081 if (bp->hwrm_spec_code < 0x10704 || !BNXT_PF(bp)) in bnxt_ethtool_init()
5084 test_info = bp->test_info; in bnxt_ethtool_init()
5086 test_info = kzalloc(sizeof(*bp->test_info), GFP_KERNEL); in bnxt_ethtool_init()
5089 bp->test_info = test_info; in bnxt_ethtool_init()
5100 bp->num_tests = resp->num_tests + BNXT_DRV_TESTS; in bnxt_ethtool_init()
5101 if (bp->num_tests > BNXT_MAX_TEST) in bnxt_ethtool_init()
5102 bp->num_tests = BNXT_MAX_TEST; in bnxt_ethtool_init()
5104 test_info->offline_mask = resp->offline_tests; in bnxt_ethtool_init()
5105 test_info->timeout = le16_to_cpu(resp->test_timeout); in bnxt_ethtool_init()
5106 if (!test_info->timeout) in bnxt_ethtool_init()
5107 test_info->timeout = HWRM_CMD_TIMEOUT; in bnxt_ethtool_init()
5108 for (i = 0; i < bp->num_tests; i++) { in bnxt_ethtool_init()
5109 char *str = test_info->string[i]; in bnxt_ethtool_init()
5110 char *fw_str = resp->test_name[i]; in bnxt_ethtool_init()
5122 fw_str, test_info->offline_mask & (1 << i) ? in bnxt_ethtool_init()
5137 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_get_eth_phy_stats()
5140 rx = bp->rx_port_stats_ext.sw_stats; in bnxt_get_eth_phy_stats()
5141 phy_stats->SymbolErrorDuringCarrier = in bnxt_get_eth_phy_stats()
5151 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_eth_mac_stats()
5154 rx = bp->port_stats.sw_stats; in bnxt_get_eth_mac_stats()
5155 tx = bp->port_stats.sw_stats + BNXT_TX_PORT_STATS_BYTE_OFFSET / 8; in bnxt_get_eth_mac_stats()
5157 mac_stats->FramesReceivedOK = in bnxt_get_eth_mac_stats()
5159 mac_stats->FramesTransmittedOK = in bnxt_get_eth_mac_stats()
5161 mac_stats->FrameCheckSequenceErrors = in bnxt_get_eth_mac_stats()
5163 mac_stats->AlignmentErrors = in bnxt_get_eth_mac_stats()
5165 mac_stats->OutOfRangeLengthField = in bnxt_get_eth_mac_stats()
5175 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_eth_ctrl_stats()
5178 rx = bp->port_stats.sw_stats; in bnxt_get_eth_ctrl_stats()
5179 ctrl_stats->MACControlFramesReceived = in bnxt_get_eth_ctrl_stats()
5204 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_rmon_stats()
5207 rx = bp->port_stats.sw_stats; in bnxt_get_rmon_stats()
5208 tx = bp->port_stats.sw_stats + BNXT_TX_PORT_STATS_BYTE_OFFSET / 8; in bnxt_get_rmon_stats()
5210 rmon_stats->jabbers = in bnxt_get_rmon_stats()
5212 rmon_stats->oversize_pkts = in bnxt_get_rmon_stats()
5214 rmon_stats->undersize_pkts = in bnxt_get_rmon_stats()
5217 rmon_stats->hist[0] = BNXT_GET_RX_PORT_STATS64(rx, rx_64b_frames); in bnxt_get_rmon_stats()
5218 rmon_stats->hist[1] = BNXT_GET_RX_PORT_STATS64(rx, rx_65b_127b_frames); in bnxt_get_rmon_stats()
5219 rmon_stats->hist[2] = BNXT_GET_RX_PORT_STATS64(rx, rx_128b_255b_frames); in bnxt_get_rmon_stats()
5220 rmon_stats->hist[3] = BNXT_GET_RX_PORT_STATS64(rx, rx_256b_511b_frames); in bnxt_get_rmon_stats()
5221 rmon_stats->hist[4] = in bnxt_get_rmon_stats()
5223 rmon_stats->hist[5] = in bnxt_get_rmon_stats()
5225 rmon_stats->hist[6] = in bnxt_get_rmon_stats()
5227 rmon_stats->hist[7] = in bnxt_get_rmon_stats()
5229 rmon_stats->hist[8] = in bnxt_get_rmon_stats()
5231 rmon_stats->hist[9] = in bnxt_get_rmon_stats()
5234 rmon_stats->hist_tx[0] = in bnxt_get_rmon_stats()
5236 rmon_stats->hist_tx[1] = in bnxt_get_rmon_stats()
5238 rmon_stats->hist_tx[2] = in bnxt_get_rmon_stats()
5240 rmon_stats->hist_tx[3] = in bnxt_get_rmon_stats()
5242 rmon_stats->hist_tx[4] = in bnxt_get_rmon_stats()
5244 rmon_stats->hist_tx[5] = in bnxt_get_rmon_stats()
5246 rmon_stats->hist_tx[6] = in bnxt_get_rmon_stats()
5248 rmon_stats->hist_tx[7] = in bnxt_get_rmon_stats()
5250 rmon_stats->hist_tx[8] = in bnxt_get_rmon_stats()
5252 rmon_stats->hist_tx[9] = in bnxt_get_rmon_stats()
5262 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_get_ptp_stats()
5265 ts_stats->pkts = ptp->stats.ts_pkts; in bnxt_get_ptp_stats()
5266 ts_stats->lost = ptp->stats.ts_lost; in bnxt_get_ptp_stats()
5267 ts_stats->err = atomic64_read(&ptp->stats.ts_err); in bnxt_get_ptp_stats()
5277 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_get_link_ext_stats()
5280 rx = bp->rx_port_stats_ext.sw_stats; in bnxt_get_link_ext_stats()
5281 stats->link_down_events = in bnxt_get_link_ext_stats()
5287 kfree(bp->test_info); in bnxt_ethtool_free()
5288 bp->test_info = NULL; in bnxt_ethtool_free()