Lines Matching +full:self +full:- +full:advertising
1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2014-2016 Broadcom Corporation
4 * Copyright (c) 2016-2017 Broadcom Limited
51 return bp->msg_enable; in bnxt_get_msglevel()
58 bp->msg_enable = value; in bnxt_set_msglevel()
72 coal->use_adaptive_rx_coalesce = bp->flags & BNXT_FLAG_DIM; in bnxt_get_coalesce()
74 hw_coal = &bp->rx_coal; in bnxt_get_coalesce()
75 mult = hw_coal->bufs_per_record; in bnxt_get_coalesce()
76 coal->rx_coalesce_usecs = hw_coal->coal_ticks; in bnxt_get_coalesce()
77 coal->rx_max_coalesced_frames = hw_coal->coal_bufs / mult; in bnxt_get_coalesce()
78 coal->rx_coalesce_usecs_irq = hw_coal->coal_ticks_irq; in bnxt_get_coalesce()
79 coal->rx_max_coalesced_frames_irq = hw_coal->coal_bufs_irq / mult; in bnxt_get_coalesce()
80 if (hw_coal->flags & in bnxt_get_coalesce()
82 kernel_coal->use_cqe_mode_rx = true; in bnxt_get_coalesce()
84 hw_coal = &bp->tx_coal; in bnxt_get_coalesce()
85 mult = hw_coal->bufs_per_record; in bnxt_get_coalesce()
86 coal->tx_coalesce_usecs = hw_coal->coal_ticks; in bnxt_get_coalesce()
87 coal->tx_max_coalesced_frames = hw_coal->coal_bufs / mult; in bnxt_get_coalesce()
88 coal->tx_coalesce_usecs_irq = hw_coal->coal_ticks_irq; in bnxt_get_coalesce()
89 coal->tx_max_coalesced_frames_irq = hw_coal->coal_bufs_irq / mult; in bnxt_get_coalesce()
90 if (hw_coal->flags & in bnxt_get_coalesce()
92 kernel_coal->use_cqe_mode_tx = true; in bnxt_get_coalesce()
94 coal->stats_block_coalesce_usecs = bp->stats_coal_ticks; in bnxt_get_coalesce()
110 if (coal->use_adaptive_rx_coalesce) { in bnxt_set_coalesce()
111 bp->flags |= BNXT_FLAG_DIM; in bnxt_set_coalesce()
113 if (bp->flags & BNXT_FLAG_DIM) { in bnxt_set_coalesce()
114 bp->flags &= ~(BNXT_FLAG_DIM); in bnxt_set_coalesce()
119 if ((kernel_coal->use_cqe_mode_rx || kernel_coal->use_cqe_mode_tx) && in bnxt_set_coalesce()
120 !(bp->coal_cap.cmpl_params & in bnxt_set_coalesce()
122 return -EOPNOTSUPP; in bnxt_set_coalesce()
124 hw_coal = &bp->rx_coal; in bnxt_set_coalesce()
125 mult = hw_coal->bufs_per_record; in bnxt_set_coalesce()
126 hw_coal->coal_ticks = coal->rx_coalesce_usecs; in bnxt_set_coalesce()
127 hw_coal->coal_bufs = coal->rx_max_coalesced_frames * mult; in bnxt_set_coalesce()
128 hw_coal->coal_ticks_irq = coal->rx_coalesce_usecs_irq; in bnxt_set_coalesce()
129 hw_coal->coal_bufs_irq = coal->rx_max_coalesced_frames_irq * mult; in bnxt_set_coalesce()
130 hw_coal->flags &= in bnxt_set_coalesce()
132 if (kernel_coal->use_cqe_mode_rx) in bnxt_set_coalesce()
133 hw_coal->flags |= in bnxt_set_coalesce()
136 hw_coal = &bp->tx_coal; in bnxt_set_coalesce()
137 mult = hw_coal->bufs_per_record; in bnxt_set_coalesce()
138 hw_coal->coal_ticks = coal->tx_coalesce_usecs; in bnxt_set_coalesce()
139 hw_coal->coal_bufs = coal->tx_max_coalesced_frames * mult; in bnxt_set_coalesce()
140 hw_coal->coal_ticks_irq = coal->tx_coalesce_usecs_irq; in bnxt_set_coalesce()
141 hw_coal->coal_bufs_irq = coal->tx_max_coalesced_frames_irq * mult; in bnxt_set_coalesce()
142 hw_coal->flags &= in bnxt_set_coalesce()
144 if (kernel_coal->use_cqe_mode_tx) in bnxt_set_coalesce()
145 hw_coal->flags |= in bnxt_set_coalesce()
148 if (bp->stats_coal_ticks != coal->stats_block_coalesce_usecs) { in bnxt_set_coalesce()
149 u32 stats_ticks = coal->stats_block_coalesce_usecs; in bnxt_set_coalesce()
157 bp->stats_coal_ticks = stats_ticks; in bnxt_set_coalesce()
158 if (bp->stats_coal_ticks) in bnxt_set_coalesce()
159 bp->current_interval = in bnxt_set_coalesce()
160 bp->stats_coal_ticks * HZ / 1000000; in bnxt_set_coalesce()
162 bp->current_interval = BNXT_TIMER_INTERVAL; in bnxt_set_coalesce()
167 if (test_bit(BNXT_STATE_OPEN, &bp->state)) { in bnxt_set_coalesce()
514 if (bp->max_tpa_v2) { in bnxt_get_num_tpa_ring_stats()
532 return rx * bp->rx_nr_rings + in bnxt_get_num_ring_stats()
533 tx * (bp->tx_nr_rings_xdp + bp->tx_nr_rings_per_tc) + in bnxt_get_num_ring_stats()
534 cmn * bp->cp_nr_rings; in bnxt_get_num_ring_stats()
544 if (bp->flags & BNXT_FLAG_PORT_STATS) in bnxt_get_num_stats()
547 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_get_num_stats()
548 len = min_t(int, bp->fw_rx_stats_ext_size, in bnxt_get_num_stats()
551 len = min_t(int, bp->fw_tx_stats_ext_size, in bnxt_get_num_stats()
554 if (bp->pri2cos_valid) in bnxt_get_num_stats()
569 if (!bp->num_tests) in bnxt_get_sset_count()
570 return -EOPNOTSUPP; in bnxt_get_sset_count()
571 return bp->num_tests; in bnxt_get_sset_count()
573 return -EOPNOTSUPP; in bnxt_get_sset_count()
579 return ring_num < bp->rx_nr_rings; in is_rx_ring()
586 if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) in is_tx_ring()
587 tx_base = bp->rx_nr_rings; in is_tx_ring()
589 if (ring_num >= tx_base && ring_num < (tx_base + bp->tx_nr_rings)) in is_tx_ring()
603 if (!bp->bnapi) { in bnxt_get_ethtool_stats()
609 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_ethtool_stats()
610 struct bnxt_napi *bnapi = bp->bnapi[i]; in bnxt_get_ethtool_stats()
611 struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; in bnxt_get_ethtool_stats()
612 u64 *sw_stats = cpr->stats.sw_stats; in bnxt_get_ethtool_stats()
635 sw = (u64 *)&cpr->sw_stats->rx; in bnxt_get_ethtool_stats()
641 sw = (u64 *)&cpr->sw_stats->cmn; in bnxt_get_ethtool_stats()
650 prev = &bp->ring_err_stats_prev.rx_total_l4_csum_errors; in bnxt_get_ethtool_stats()
654 if (bp->flags & BNXT_FLAG_PORT_STATS) { in bnxt_get_ethtool_stats()
655 u64 *port_stats = bp->port_stats.sw_stats; in bnxt_get_ethtool_stats()
660 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_get_ethtool_stats()
661 u64 *rx_port_stats_ext = bp->rx_port_stats_ext.sw_stats; in bnxt_get_ethtool_stats()
662 u64 *tx_port_stats_ext = bp->tx_port_stats_ext.sw_stats; in bnxt_get_ethtool_stats()
665 len = min_t(u32, bp->fw_rx_stats_ext_size, in bnxt_get_ethtool_stats()
671 len = min_t(u32, bp->fw_tx_stats_ext_size, in bnxt_get_ethtool_stats()
677 if (bp->pri2cos_valid) { in bnxt_get_ethtool_stats()
680 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
686 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
692 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
698 bp->pri2cos_idx[i]; in bnxt_get_ethtool_stats()
714 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_get_strings()
731 if (bp->max_tpa_v2) in bnxt_get_strings()
758 if (bp->flags & BNXT_FLAG_PORT_STATS) in bnxt_get_strings()
764 if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { in bnxt_get_strings()
767 len = min_t(u32, bp->fw_rx_stats_ext_size, in bnxt_get_strings()
774 len = min_t(u32, bp->fw_tx_stats_ext_size, in bnxt_get_strings()
781 if (bp->pri2cos_valid) { in bnxt_get_strings()
805 if (bp->num_tests) in bnxt_get_strings()
806 for (i = 0; i < bp->num_tests; i++) in bnxt_get_strings()
807 ethtool_puts(&buf, bp->test_info->string[i]); in bnxt_get_strings()
810 netdev_err(bp->dev, "bnxt_get_strings invalid request %x\n", in bnxt_get_strings()
823 if (bp->flags & BNXT_FLAG_AGG_RINGS) { in bnxt_get_ringparam()
824 ering->rx_max_pending = BNXT_MAX_RX_DESC_CNT_JUM_ENA; in bnxt_get_ringparam()
825 ering->rx_jumbo_max_pending = BNXT_MAX_RX_JUM_DESC_CNT; in bnxt_get_ringparam()
826 kernel_ering->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_ENABLED; in bnxt_get_ringparam()
828 ering->rx_max_pending = BNXT_MAX_RX_DESC_CNT; in bnxt_get_ringparam()
829 ering->rx_jumbo_max_pending = 0; in bnxt_get_ringparam()
830 kernel_ering->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_DISABLED; in bnxt_get_ringparam()
832 ering->tx_max_pending = BNXT_MAX_TX_DESC_CNT; in bnxt_get_ringparam()
834 ering->rx_pending = bp->rx_ring_size; in bnxt_get_ringparam()
835 ering->rx_jumbo_pending = bp->rx_agg_ring_size; in bnxt_get_ringparam()
836 ering->tx_pending = bp->tx_ring_size; in bnxt_get_ringparam()
838 kernel_ering->hds_thresh_max = BNXT_HDS_THRESHOLD_MAX; in bnxt_get_ringparam()
846 u8 tcp_data_split = kernel_ering->tcp_data_split; in bnxt_set_ringparam()
850 if ((ering->rx_pending > BNXT_MAX_RX_DESC_CNT) || in bnxt_set_ringparam()
851 (ering->tx_pending > BNXT_MAX_TX_DESC_CNT) || in bnxt_set_ringparam()
852 (ering->tx_pending < BNXT_MIN_TX_DESC_CNT)) in bnxt_set_ringparam()
853 return -EINVAL; in bnxt_set_ringparam()
855 hds_config_mod = tcp_data_split != dev->cfg->hds_config; in bnxt_set_ringparam()
857 return -EINVAL; in bnxt_set_ringparam()
861 NL_SET_ERR_MSG_MOD(extack, "tcp-data-split is disallowed when XDP is attached"); in bnxt_set_ringparam()
862 return -EINVAL; in bnxt_set_ringparam()
870 bp->flags |= BNXT_FLAG_HDS; in bnxt_set_ringparam()
872 bp->flags &= ~BNXT_FLAG_HDS; in bnxt_set_ringparam()
875 bp->rx_ring_size = ering->rx_pending; in bnxt_set_ringparam()
876 bp->tx_ring_size = ering->tx_pending; in bnxt_set_ringparam()
889 struct bnxt_hw_resc *hw_resc = &bp->hw_resc; in bnxt_get_channels()
893 /* Get the most up-to-date max_tx_sch_inputs. */ in bnxt_get_channels()
896 max_tx_sch_inputs = hw_resc->max_tx_sch_inputs; in bnxt_get_channels()
902 tcs = bp->num_tc; in bnxt_get_channels()
904 if (bp->tx_nr_rings_xdp) in bnxt_get_channels()
907 channel->max_combined = min_t(int, max_rx_rings, max_tx_rings); in bnxt_get_channels()
919 channel->max_rx = max_rx_rings; in bnxt_get_channels()
920 channel->max_tx = max_tx_rings; in bnxt_get_channels()
921 channel->max_other = 0; in bnxt_get_channels()
922 if (bp->flags & BNXT_FLAG_SHARED_RINGS) { in bnxt_get_channels()
923 channel->combined_count = bp->rx_nr_rings; in bnxt_get_channels()
925 channel->combined_count--; in bnxt_get_channels()
928 channel->rx_count = bp->rx_nr_rings; in bnxt_get_channels()
929 channel->tx_count = bp->tx_nr_rings_per_tc; in bnxt_get_channels()
944 if (channel->other_count) in bnxt_set_channels()
945 return -EINVAL; in bnxt_set_channels()
947 if (!channel->combined_count && in bnxt_set_channels()
948 (!channel->rx_count || !channel->tx_count)) in bnxt_set_channels()
949 return -EINVAL; in bnxt_set_channels()
951 if (channel->combined_count && in bnxt_set_channels()
952 (channel->rx_count || channel->tx_count)) in bnxt_set_channels()
953 return -EINVAL; in bnxt_set_channels()
955 if (BNXT_CHIP_TYPE_NITRO_A0(bp) && (channel->rx_count || in bnxt_set_channels()
956 channel->tx_count)) in bnxt_set_channels()
957 return -EINVAL; in bnxt_set_channels()
959 if (channel->combined_count) in bnxt_set_channels()
962 tcs = bp->num_tc; in bnxt_set_channels()
964 req_tx_rings = sh ? channel->combined_count : channel->tx_count; in bnxt_set_channels()
965 req_rx_rings = sh ? channel->combined_count : channel->rx_count; in bnxt_set_channels()
966 if (bp->tx_nr_rings_xdp) { in bnxt_set_channels()
969 return -EINVAL; in bnxt_set_channels()
975 bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) && in bnxt_set_channels()
978 return -EINVAL; in bnxt_set_channels()
997 bp->flags |= BNXT_FLAG_SHARED_RINGS; in bnxt_set_channels()
998 bp->rx_nr_rings = channel->combined_count; in bnxt_set_channels()
999 bp->tx_nr_rings_per_tc = channel->combined_count; in bnxt_set_channels()
1001 bp->flags &= ~BNXT_FLAG_SHARED_RINGS; in bnxt_set_channels()
1002 bp->rx_nr_rings = channel->rx_count; in bnxt_set_channels()
1003 bp->tx_nr_rings_per_tc = channel->tx_count; in bnxt_set_channels()
1005 bp->tx_nr_rings_xdp = tx_xdp; in bnxt_set_channels()
1006 bp->tx_nr_rings = bp->tx_nr_rings_per_tc + tx_xdp; in bnxt_set_channels()
1008 bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs + tx_xdp; in bnxt_set_channels()
1010 tx_cp = bnxt_num_tx_to_cp(bp, bp->tx_nr_rings); in bnxt_set_channels()
1011 bp->cp_nr_rings = sh ? max_t(int, tx_cp, bp->rx_nr_rings) : in bnxt_set_channels()
1012 tx_cp + bp->rx_nr_rings; in bnxt_set_channels()
1044 if (!fltr->flags || in bnxt_get_all_fltr_ids_rcu()
1045 test_bit(BNXT_FLTR_FW_DELETED, &fltr->state)) in bnxt_get_all_fltr_ids_rcu()
1047 ids[j++] = fltr->sw_id; in bnxt_get_all_fltr_ids_rcu()
1067 if (fltr->flags && fltr->sw_id == id) in bnxt_get_one_fltr_rcu()
1079 cmd->data = bp->ntp_fltr_count; in bnxt_grxclsrlall()
1081 count = bnxt_get_all_fltr_ids_rcu(bp, bp->l2_fltr_hash_tbl, in bnxt_grxclsrlall()
1083 cmd->rule_cnt); in bnxt_grxclsrlall()
1084 cmd->rule_cnt = bnxt_get_all_fltr_ids_rcu(bp, bp->ntp_fltr_hash_tbl, in bnxt_grxclsrlall()
1087 cmd->rule_cnt); in bnxt_grxclsrlall()
1096 (struct ethtool_rx_flow_spec *)&cmd->fs; in bnxt_grxclsrule()
1101 int rc = -EINVAL; in bnxt_grxclsrule()
1103 if (fs->location >= bp->max_fltr) in bnxt_grxclsrule()
1107 fltr_base = bnxt_get_one_fltr_rcu(bp, bp->l2_fltr_hash_tbl, in bnxt_grxclsrule()
1109 fs->location); in bnxt_grxclsrule()
1111 struct ethhdr *h_ether = &fs->h_u.ether_spec; in bnxt_grxclsrule()
1112 struct ethhdr *m_ether = &fs->m_u.ether_spec; in bnxt_grxclsrule()
1117 l2_key = &l2_fltr->l2_key; in bnxt_grxclsrule()
1118 fs->flow_type = ETHER_FLOW; in bnxt_grxclsrule()
1119 ether_addr_copy(h_ether->h_dest, l2_key->dst_mac_addr); in bnxt_grxclsrule()
1120 eth_broadcast_addr(m_ether->h_dest); in bnxt_grxclsrule()
1121 if (l2_key->vlan) { in bnxt_grxclsrule()
1122 struct ethtool_flow_ext *m_ext = &fs->m_ext; in bnxt_grxclsrule()
1123 struct ethtool_flow_ext *h_ext = &fs->h_ext; in bnxt_grxclsrule()
1125 fs->flow_type |= FLOW_EXT; in bnxt_grxclsrule()
1126 m_ext->vlan_tci = htons(0xfff); in bnxt_grxclsrule()
1127 h_ext->vlan_tci = htons(l2_key->vlan); in bnxt_grxclsrule()
1129 if (fltr_base->flags & BNXT_ACT_RING_DST) in bnxt_grxclsrule()
1130 fs->ring_cookie = fltr_base->rxq; in bnxt_grxclsrule()
1131 if (fltr_base->flags & BNXT_ACT_FUNC_DST) in bnxt_grxclsrule()
1132 fs->ring_cookie = (u64)(fltr_base->vf_idx + 1) << in bnxt_grxclsrule()
1137 fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, in bnxt_grxclsrule()
1139 fs->location); in bnxt_grxclsrule()
1146 fkeys = &fltr->fkeys; in bnxt_grxclsrule()
1147 fmasks = &fltr->fmasks; in bnxt_grxclsrule()
1148 if (fkeys->basic.n_proto == htons(ETH_P_IP)) { in bnxt_grxclsrule()
1149 if (fkeys->basic.ip_proto == BNXT_IP_PROTO_WILDCARD) { in bnxt_grxclsrule()
1150 fs->flow_type = IP_USER_FLOW; in bnxt_grxclsrule()
1151 fs->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; in bnxt_grxclsrule()
1152 fs->h_u.usr_ip4_spec.proto = BNXT_IP_PROTO_WILDCARD; in bnxt_grxclsrule()
1153 fs->m_u.usr_ip4_spec.proto = 0; in bnxt_grxclsrule()
1154 } else if (fkeys->basic.ip_proto == IPPROTO_ICMP) { in bnxt_grxclsrule()
1155 fs->flow_type = IP_USER_FLOW; in bnxt_grxclsrule()
1156 fs->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; in bnxt_grxclsrule()
1157 fs->h_u.usr_ip4_spec.proto = IPPROTO_ICMP; in bnxt_grxclsrule()
1158 fs->m_u.usr_ip4_spec.proto = BNXT_IP_PROTO_FULL_MASK; in bnxt_grxclsrule()
1159 } else if (fkeys->basic.ip_proto == IPPROTO_TCP) { in bnxt_grxclsrule()
1160 fs->flow_type = TCP_V4_FLOW; in bnxt_grxclsrule()
1161 } else if (fkeys->basic.ip_proto == IPPROTO_UDP) { in bnxt_grxclsrule()
1162 fs->flow_type = UDP_V4_FLOW; in bnxt_grxclsrule()
1167 fs->h_u.tcp_ip4_spec.ip4src = fkeys->addrs.v4addrs.src; in bnxt_grxclsrule()
1168 fs->m_u.tcp_ip4_spec.ip4src = fmasks->addrs.v4addrs.src; in bnxt_grxclsrule()
1169 fs->h_u.tcp_ip4_spec.ip4dst = fkeys->addrs.v4addrs.dst; in bnxt_grxclsrule()
1170 fs->m_u.tcp_ip4_spec.ip4dst = fmasks->addrs.v4addrs.dst; in bnxt_grxclsrule()
1171 if (fs->flow_type == TCP_V4_FLOW || in bnxt_grxclsrule()
1172 fs->flow_type == UDP_V4_FLOW) { in bnxt_grxclsrule()
1173 fs->h_u.tcp_ip4_spec.psrc = fkeys->ports.src; in bnxt_grxclsrule()
1174 fs->m_u.tcp_ip4_spec.psrc = fmasks->ports.src; in bnxt_grxclsrule()
1175 fs->h_u.tcp_ip4_spec.pdst = fkeys->ports.dst; in bnxt_grxclsrule()
1176 fs->m_u.tcp_ip4_spec.pdst = fmasks->ports.dst; in bnxt_grxclsrule()
1179 if (fkeys->basic.ip_proto == BNXT_IP_PROTO_WILDCARD) { in bnxt_grxclsrule()
1180 fs->flow_type = IPV6_USER_FLOW; in bnxt_grxclsrule()
1181 fs->h_u.usr_ip6_spec.l4_proto = BNXT_IP_PROTO_WILDCARD; in bnxt_grxclsrule()
1182 fs->m_u.usr_ip6_spec.l4_proto = 0; in bnxt_grxclsrule()
1183 } else if (fkeys->basic.ip_proto == IPPROTO_ICMPV6) { in bnxt_grxclsrule()
1184 fs->flow_type = IPV6_USER_FLOW; in bnxt_grxclsrule()
1185 fs->h_u.usr_ip6_spec.l4_proto = IPPROTO_ICMPV6; in bnxt_grxclsrule()
1186 fs->m_u.usr_ip6_spec.l4_proto = BNXT_IP_PROTO_FULL_MASK; in bnxt_grxclsrule()
1187 } else if (fkeys->basic.ip_proto == IPPROTO_TCP) { in bnxt_grxclsrule()
1188 fs->flow_type = TCP_V6_FLOW; in bnxt_grxclsrule()
1189 } else if (fkeys->basic.ip_proto == IPPROTO_UDP) { in bnxt_grxclsrule()
1190 fs->flow_type = UDP_V6_FLOW; in bnxt_grxclsrule()
1195 *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6src[0] = in bnxt_grxclsrule()
1196 fkeys->addrs.v6addrs.src; in bnxt_grxclsrule()
1197 *(struct in6_addr *)&fs->m_u.tcp_ip6_spec.ip6src[0] = in bnxt_grxclsrule()
1198 fmasks->addrs.v6addrs.src; in bnxt_grxclsrule()
1199 *(struct in6_addr *)&fs->h_u.tcp_ip6_spec.ip6dst[0] = in bnxt_grxclsrule()
1200 fkeys->addrs.v6addrs.dst; in bnxt_grxclsrule()
1201 *(struct in6_addr *)&fs->m_u.tcp_ip6_spec.ip6dst[0] = in bnxt_grxclsrule()
1202 fmasks->addrs.v6addrs.dst; in bnxt_grxclsrule()
1203 if (fs->flow_type == TCP_V6_FLOW || in bnxt_grxclsrule()
1204 fs->flow_type == UDP_V6_FLOW) { in bnxt_grxclsrule()
1205 fs->h_u.tcp_ip6_spec.psrc = fkeys->ports.src; in bnxt_grxclsrule()
1206 fs->m_u.tcp_ip6_spec.psrc = fmasks->ports.src; in bnxt_grxclsrule()
1207 fs->h_u.tcp_ip6_spec.pdst = fkeys->ports.dst; in bnxt_grxclsrule()
1208 fs->m_u.tcp_ip6_spec.pdst = fmasks->ports.dst; in bnxt_grxclsrule()
1212 if (fltr->base.flags & BNXT_ACT_DROP) { in bnxt_grxclsrule()
1213 fs->ring_cookie = RX_CLS_FLOW_DISC; in bnxt_grxclsrule()
1214 } else if (fltr->base.flags & BNXT_ACT_RSS_CTX) { in bnxt_grxclsrule()
1215 fs->flow_type |= FLOW_RSS; in bnxt_grxclsrule()
1216 cmd->rss_context = fltr->base.fw_vnic_id; in bnxt_grxclsrule()
1218 fs->ring_cookie = fltr->base.rxq; in bnxt_grxclsrule()
1233 ctx = xa_load(&bp->dev->ethtool->rss_ctx, index); in bnxt_get_rss_ctx_from_index()
1244 vnic->rss_table_size = size + HW_HASH_KEY_SIZE; in bnxt_alloc_vnic_rss_table()
1245 vnic->rss_table = dma_alloc_coherent(&bp->pdev->dev, in bnxt_alloc_vnic_rss_table()
1246 vnic->rss_table_size, in bnxt_alloc_vnic_rss_table()
1247 &vnic->rss_table_dma_addr, in bnxt_alloc_vnic_rss_table()
1249 if (!vnic->rss_table) in bnxt_alloc_vnic_rss_table()
1250 return -ENOMEM; in bnxt_alloc_vnic_rss_table()
1252 vnic->rss_hash_key = ((void *)vnic->rss_table) + size; in bnxt_alloc_vnic_rss_table()
1253 vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + size; in bnxt_alloc_vnic_rss_table()
1260 u32 ring = ethtool_get_flow_spec_ring(fs->ring_cookie); in bnxt_add_l2_cls_rule()
1261 u8 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); in bnxt_add_l2_cls_rule()
1262 struct ethhdr *h_ether = &fs->h_u.ether_spec; in bnxt_add_l2_cls_rule()
1263 struct ethhdr *m_ether = &fs->m_u.ether_spec; in bnxt_add_l2_cls_rule()
1271 return -EOPNOTSUPP; in bnxt_add_l2_cls_rule()
1273 if (!is_broadcast_ether_addr(m_ether->h_dest)) in bnxt_add_l2_cls_rule()
1274 return -EINVAL; in bnxt_add_l2_cls_rule()
1275 ether_addr_copy(key.dst_mac_addr, h_ether->h_dest); in bnxt_add_l2_cls_rule()
1277 if (fs->flow_type & FLOW_EXT) { in bnxt_add_l2_cls_rule()
1278 struct ethtool_flow_ext *m_ext = &fs->m_ext; in bnxt_add_l2_cls_rule()
1279 struct ethtool_flow_ext *h_ext = &fs->h_ext; in bnxt_add_l2_cls_rule()
1281 if (m_ext->vlan_tci != htons(0xfff) || !h_ext->vlan_tci) in bnxt_add_l2_cls_rule()
1282 return -EINVAL; in bnxt_add_l2_cls_rule()
1283 key.vlan = ntohs(h_ext->vlan_tci); in bnxt_add_l2_cls_rule()
1289 vf--; in bnxt_add_l2_cls_rule()
1292 vnic_id = bp->vnic_info[ring + 1].fw_vnic_id; in bnxt_add_l2_cls_rule()
1298 fltr->base.fw_vnic_id = vnic_id; in bnxt_add_l2_cls_rule()
1299 fltr->base.rxq = ring; in bnxt_add_l2_cls_rule()
1300 fltr->base.vf_idx = vf; in bnxt_add_l2_cls_rule()
1305 fs->location = fltr->base.sw_id; in bnxt_add_l2_cls_rule()
1312 u8 mproto = ip_mask->proto; in bnxt_verify_ntuple_ip4_flow()
1313 u8 sproto = ip_spec->proto; in bnxt_verify_ntuple_ip4_flow()
1315 if (ip_mask->l4_4_bytes || ip_mask->tos || in bnxt_verify_ntuple_ip4_flow()
1316 ip_spec->ip_ver != ETH_RX_NFC_IP4 || in bnxt_verify_ntuple_ip4_flow()
1325 u8 mproto = ip_mask->l4_proto; in bnxt_verify_ntuple_ip6_flow()
1326 u8 sproto = ip_spec->l4_proto; in bnxt_verify_ntuple_ip6_flow()
1328 if (ip_mask->l4_4_bytes || ip_mask->tclass || in bnxt_verify_ntuple_ip6_flow()
1337 struct ethtool_rx_flow_spec *fs = &cmd->fs; in bnxt_add_ntuple_cls_rule()
1339 u32 flow_type = fs->flow_type & 0xff; in bnxt_add_ntuple_cls_rule()
1347 if (!bp->vnic_info) in bnxt_add_ntuple_cls_rule()
1348 return -EAGAIN; in bnxt_add_ntuple_cls_rule()
1350 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); in bnxt_add_ntuple_cls_rule()
1351 ring = ethtool_get_flow_spec_ring(fs->ring_cookie); in bnxt_add_ntuple_cls_rule()
1352 if ((fs->flow_type & (FLOW_MAC_EXT | FLOW_EXT)) || vf) in bnxt_add_ntuple_cls_rule()
1353 return -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1356 if (!bnxt_verify_ntuple_ip4_flow(&fs->h_u.usr_ip4_spec, in bnxt_add_ntuple_cls_rule()
1357 &fs->m_u.usr_ip4_spec)) in bnxt_add_ntuple_cls_rule()
1358 return -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1362 if (!bnxt_verify_ntuple_ip6_flow(&fs->h_u.usr_ip6_spec, in bnxt_add_ntuple_cls_rule()
1363 &fs->m_u.usr_ip6_spec)) in bnxt_add_ntuple_cls_rule()
1364 return -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1369 return -ENOMEM; in bnxt_add_ntuple_cls_rule()
1371 l2_fltr = bp->vnic_info[BNXT_VNIC_DEFAULT].l2_filters[0]; in bnxt_add_ntuple_cls_rule()
1372 atomic_inc(&l2_fltr->refcnt); in bnxt_add_ntuple_cls_rule()
1373 new_fltr->l2_fltr = l2_fltr; in bnxt_add_ntuple_cls_rule()
1374 fmasks = &new_fltr->fmasks; in bnxt_add_ntuple_cls_rule()
1375 fkeys = &new_fltr->fkeys; in bnxt_add_ntuple_cls_rule()
1377 rc = -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1380 struct ethtool_usrip4_spec *ip_spec = &fs->h_u.usr_ip4_spec; in bnxt_add_ntuple_cls_rule()
1381 struct ethtool_usrip4_spec *ip_mask = &fs->m_u.usr_ip4_spec; in bnxt_add_ntuple_cls_rule()
1383 fkeys->basic.ip_proto = ip_mask->proto ? ip_spec->proto in bnxt_add_ntuple_cls_rule()
1385 fkeys->basic.n_proto = htons(ETH_P_IP); in bnxt_add_ntuple_cls_rule()
1386 fkeys->addrs.v4addrs.src = ip_spec->ip4src; in bnxt_add_ntuple_cls_rule()
1387 fmasks->addrs.v4addrs.src = ip_mask->ip4src; in bnxt_add_ntuple_cls_rule()
1388 fkeys->addrs.v4addrs.dst = ip_spec->ip4dst; in bnxt_add_ntuple_cls_rule()
1389 fmasks->addrs.v4addrs.dst = ip_mask->ip4dst; in bnxt_add_ntuple_cls_rule()
1394 struct ethtool_tcpip4_spec *ip_spec = &fs->h_u.tcp_ip4_spec; in bnxt_add_ntuple_cls_rule()
1395 struct ethtool_tcpip4_spec *ip_mask = &fs->m_u.tcp_ip4_spec; in bnxt_add_ntuple_cls_rule()
1397 fkeys->basic.ip_proto = IPPROTO_TCP; in bnxt_add_ntuple_cls_rule()
1399 fkeys->basic.ip_proto = IPPROTO_UDP; in bnxt_add_ntuple_cls_rule()
1400 fkeys->basic.n_proto = htons(ETH_P_IP); in bnxt_add_ntuple_cls_rule()
1401 fkeys->addrs.v4addrs.src = ip_spec->ip4src; in bnxt_add_ntuple_cls_rule()
1402 fmasks->addrs.v4addrs.src = ip_mask->ip4src; in bnxt_add_ntuple_cls_rule()
1403 fkeys->addrs.v4addrs.dst = ip_spec->ip4dst; in bnxt_add_ntuple_cls_rule()
1404 fmasks->addrs.v4addrs.dst = ip_mask->ip4dst; in bnxt_add_ntuple_cls_rule()
1405 fkeys->ports.src = ip_spec->psrc; in bnxt_add_ntuple_cls_rule()
1406 fmasks->ports.src = ip_mask->psrc; in bnxt_add_ntuple_cls_rule()
1407 fkeys->ports.dst = ip_spec->pdst; in bnxt_add_ntuple_cls_rule()
1408 fmasks->ports.dst = ip_mask->pdst; in bnxt_add_ntuple_cls_rule()
1412 struct ethtool_usrip6_spec *ip_spec = &fs->h_u.usr_ip6_spec; in bnxt_add_ntuple_cls_rule()
1413 struct ethtool_usrip6_spec *ip_mask = &fs->m_u.usr_ip6_spec; in bnxt_add_ntuple_cls_rule()
1415 fkeys->basic.ip_proto = ip_mask->l4_proto ? ip_spec->l4_proto in bnxt_add_ntuple_cls_rule()
1417 fkeys->basic.n_proto = htons(ETH_P_IPV6); in bnxt_add_ntuple_cls_rule()
1418 fkeys->addrs.v6addrs.src = *(struct in6_addr *)&ip_spec->ip6src; in bnxt_add_ntuple_cls_rule()
1419 fmasks->addrs.v6addrs.src = *(struct in6_addr *)&ip_mask->ip6src; in bnxt_add_ntuple_cls_rule()
1420 fkeys->addrs.v6addrs.dst = *(struct in6_addr *)&ip_spec->ip6dst; in bnxt_add_ntuple_cls_rule()
1421 fmasks->addrs.v6addrs.dst = *(struct in6_addr *)&ip_mask->ip6dst; in bnxt_add_ntuple_cls_rule()
1426 struct ethtool_tcpip6_spec *ip_spec = &fs->h_u.tcp_ip6_spec; in bnxt_add_ntuple_cls_rule()
1427 struct ethtool_tcpip6_spec *ip_mask = &fs->m_u.tcp_ip6_spec; in bnxt_add_ntuple_cls_rule()
1429 fkeys->basic.ip_proto = IPPROTO_TCP; in bnxt_add_ntuple_cls_rule()
1431 fkeys->basic.ip_proto = IPPROTO_UDP; in bnxt_add_ntuple_cls_rule()
1432 fkeys->basic.n_proto = htons(ETH_P_IPV6); in bnxt_add_ntuple_cls_rule()
1434 fkeys->addrs.v6addrs.src = *(struct in6_addr *)&ip_spec->ip6src; in bnxt_add_ntuple_cls_rule()
1435 fmasks->addrs.v6addrs.src = *(struct in6_addr *)&ip_mask->ip6src; in bnxt_add_ntuple_cls_rule()
1436 fkeys->addrs.v6addrs.dst = *(struct in6_addr *)&ip_spec->ip6dst; in bnxt_add_ntuple_cls_rule()
1437 fmasks->addrs.v6addrs.dst = *(struct in6_addr *)&ip_mask->ip6dst; in bnxt_add_ntuple_cls_rule()
1438 fkeys->ports.src = ip_spec->psrc; in bnxt_add_ntuple_cls_rule()
1439 fmasks->ports.src = ip_mask->psrc; in bnxt_add_ntuple_cls_rule()
1440 fkeys->ports.dst = ip_spec->pdst; in bnxt_add_ntuple_cls_rule()
1441 fmasks->ports.dst = ip_mask->pdst; in bnxt_add_ntuple_cls_rule()
1445 rc = -EOPNOTSUPP; in bnxt_add_ntuple_cls_rule()
1456 rc = -EEXIST; in bnxt_add_ntuple_cls_rule()
1461 new_fltr->base.flags = BNXT_ACT_NO_AGING; in bnxt_add_ntuple_cls_rule()
1462 if (fs->flow_type & FLOW_RSS) { in bnxt_add_ntuple_cls_rule()
1465 new_fltr->base.fw_vnic_id = 0; in bnxt_add_ntuple_cls_rule()
1466 new_fltr->base.flags |= BNXT_ACT_RSS_CTX; in bnxt_add_ntuple_cls_rule()
1467 rss_ctx = bnxt_get_rss_ctx_from_index(bp, cmd->rss_context); in bnxt_add_ntuple_cls_rule()
1469 new_fltr->base.fw_vnic_id = rss_ctx->index; in bnxt_add_ntuple_cls_rule()
1471 rc = -EINVAL; in bnxt_add_ntuple_cls_rule()
1475 if (fs->ring_cookie == RX_CLS_FLOW_DISC) in bnxt_add_ntuple_cls_rule()
1476 new_fltr->base.flags |= BNXT_ACT_DROP; in bnxt_add_ntuple_cls_rule()
1478 new_fltr->base.rxq = ring; in bnxt_add_ntuple_cls_rule()
1479 __set_bit(BNXT_FLTR_VALID, &new_fltr->base.state); in bnxt_add_ntuple_cls_rule()
1487 fs->location = new_fltr->base.sw_id; in bnxt_add_ntuple_cls_rule()
1492 atomic_dec(&l2_fltr->refcnt); in bnxt_add_ntuple_cls_rule()
1499 struct ethtool_rx_flow_spec *fs = &cmd->fs; in bnxt_srxclsrlins()
1504 if (!netif_running(bp->dev)) in bnxt_srxclsrlins()
1505 return -EAGAIN; in bnxt_srxclsrlins()
1506 if (!(bp->flags & BNXT_FLAG_RFS)) in bnxt_srxclsrlins()
1507 return -EPERM; in bnxt_srxclsrlins()
1508 if (fs->location != RX_CLS_LOC_ANY) in bnxt_srxclsrlins()
1509 return -EINVAL; in bnxt_srxclsrlins()
1511 flow_type = fs->flow_type; in bnxt_srxclsrlins()
1514 !(bp->fw_cap & BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO)) in bnxt_srxclsrlins()
1515 return -EOPNOTSUPP; in bnxt_srxclsrlins()
1517 return -EINVAL; in bnxt_srxclsrlins()
1520 if (fs->ring_cookie == RX_CLS_FLOW_DISC && flow_type != ETHER_FLOW) in bnxt_srxclsrlins()
1523 ring = ethtool_get_flow_spec_ring(fs->ring_cookie); in bnxt_srxclsrlins()
1524 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie); in bnxt_srxclsrlins()
1526 return -EINVAL; in bnxt_srxclsrlins()
1527 if (BNXT_PF(bp) && vf > bp->pf.active_vfs) in bnxt_srxclsrlins()
1528 return -EINVAL; in bnxt_srxclsrlins()
1529 if (!vf && ring >= bp->rx_nr_rings) in bnxt_srxclsrlins()
1530 return -EINVAL; in bnxt_srxclsrlins()
1541 struct ethtool_rx_flow_spec *fs = &cmd->fs; in bnxt_srxclsrldel()
1544 u32 id = fs->location; in bnxt_srxclsrldel()
1547 fltr_base = bnxt_get_one_fltr_rcu(bp, bp->l2_fltr_hash_tbl, in bnxt_srxclsrldel()
1558 fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, in bnxt_srxclsrldel()
1562 return -ENOENT; in bnxt_srxclsrldel()
1566 if (!(fltr->base.flags & BNXT_ACT_NO_AGING)) { in bnxt_srxclsrldel()
1568 return -EINVAL; in bnxt_srxclsrldel()
1578 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4) in get_ethtool_ipv4_rss()
1585 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6) in get_ethtool_ipv6_rss()
1592 cmd->data = 0; in bnxt_grxfh()
1593 switch (cmd->flow_type) { in bnxt_grxfh()
1595 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4) in bnxt_grxfh()
1596 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1598 cmd->data |= get_ethtool_ipv4_rss(bp); in bnxt_grxfh()
1601 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4) 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_ipv4_rss(bp); in bnxt_grxfh()
1620 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6) in bnxt_grxfh()
1621 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1623 cmd->data |= get_ethtool_ipv6_rss(bp); in bnxt_grxfh()
1626 if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6) in bnxt_grxfh()
1627 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1631 if (bp->rss_hash_cfg & in bnxt_grxfh()
1634 cmd->data |= RXH_IP_SRC | RXH_IP_DST | in bnxt_grxfh()
1641 cmd->data |= get_ethtool_ipv6_rss(bp); in bnxt_grxfh()
1652 u32 rss_hash_cfg = bp->rss_hash_cfg; in bnxt_srxfh()
1655 if (cmd->data == RXH_4TUPLE) in bnxt_srxfh()
1657 else if (cmd->data == RXH_2TUPLE) in bnxt_srxfh()
1659 else if (!cmd->data) in bnxt_srxfh()
1662 return -EINVAL; in bnxt_srxfh()
1664 if (cmd->flow_type == TCP_V4_FLOW) { in bnxt_srxfh()
1668 } else if (cmd->flow_type == UDP_V4_FLOW) { in bnxt_srxfh()
1669 if (tuple == 4 && !(bp->rss_cap & BNXT_RSS_CAP_UDP_RSS_CAP)) in bnxt_srxfh()
1670 return -EINVAL; in bnxt_srxfh()
1674 } else if (cmd->flow_type == TCP_V6_FLOW) { in bnxt_srxfh()
1678 } else if (cmd->flow_type == UDP_V6_FLOW) { in bnxt_srxfh()
1679 if (tuple == 4 && !(bp->rss_cap & BNXT_RSS_CAP_UDP_RSS_CAP)) in bnxt_srxfh()
1680 return -EINVAL; in bnxt_srxfh()
1684 } else if (cmd->flow_type == AH_ESP_V4_FLOW) { in bnxt_srxfh()
1685 if (tuple == 4 && (!(bp->rss_cap & BNXT_RSS_CAP_AH_V4_RSS_CAP) || in bnxt_srxfh()
1686 !(bp->rss_cap & BNXT_RSS_CAP_ESP_V4_RSS_CAP))) in bnxt_srxfh()
1687 return -EINVAL; in bnxt_srxfh()
1693 } else if (cmd->flow_type == AH_ESP_V6_FLOW) { in bnxt_srxfh()
1694 if (tuple == 4 && (!(bp->rss_cap & BNXT_RSS_CAP_AH_V6_RSS_CAP) || in bnxt_srxfh()
1695 !(bp->rss_cap & BNXT_RSS_CAP_ESP_V6_RSS_CAP))) in bnxt_srxfh()
1696 return -EINVAL; in bnxt_srxfh()
1703 return -EINVAL; in bnxt_srxfh()
1706 switch (cmd->flow_type) { in bnxt_srxfh()
1734 if (bp->rss_hash_cfg == rss_hash_cfg) in bnxt_srxfh()
1737 if (bp->rss_cap & BNXT_RSS_CAP_RSS_HASH_TYPE_DELTA) in bnxt_srxfh()
1738 bp->rss_hash_delta = bp->rss_hash_cfg ^ rss_hash_cfg; in bnxt_srxfh()
1739 bp->rss_hash_cfg = rss_hash_cfg; in bnxt_srxfh()
1740 if (netif_running(bp->dev)) { in bnxt_srxfh()
1753 switch (cmd->cmd) { in bnxt_get_rxnfc()
1755 cmd->data = bp->rx_nr_rings; in bnxt_get_rxnfc()
1759 cmd->rule_cnt = bp->ntp_fltr_count; in bnxt_get_rxnfc()
1760 cmd->data = bp->max_fltr | RX_CLS_LOC_SPECIAL; in bnxt_get_rxnfc()
1776 rc = -EOPNOTSUPP; in bnxt_get_rxnfc()
1788 switch (cmd->cmd) { in bnxt_set_rxnfc()
1802 rc = -EOPNOTSUPP; in bnxt_set_rxnfc()
1812 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_get_rxfh_indir_size()
1813 return bnxt_get_nr_rss_ctxs(bp, bp->rx_nr_rings) * in bnxt_get_rxfh_indir_size()
1828 u32 *indir_tbl = bp->rss_indir_tbl; in bnxt_get_rxfh()
1832 rxfh->hfunc = ETH_RSS_HASH_TOP; in bnxt_get_rxfh()
1834 if (!bp->vnic_info) in bnxt_get_rxfh()
1837 vnic = &bp->vnic_info[BNXT_VNIC_DEFAULT]; in bnxt_get_rxfh()
1838 if (rxfh->rss_context) { in bnxt_get_rxfh()
1841 ctx = xa_load(&bp->dev->ethtool->rss_ctx, rxfh->rss_context); in bnxt_get_rxfh()
1843 return -EINVAL; in bnxt_get_rxfh()
1846 vnic = &rss_ctx->vnic; in bnxt_get_rxfh()
1849 if (rxfh->indir && indir_tbl) { in bnxt_get_rxfh()
1852 rxfh->indir[i] = indir_tbl[i]; in bnxt_get_rxfh()
1855 if (rxfh->key && vnic->rss_hash_key) in bnxt_get_rxfh()
1856 memcpy(rxfh->key, vnic->rss_hash_key, HW_HASH_KEY_SIZE); in bnxt_get_rxfh()
1865 if (rxfh->key) { in bnxt_modify_rss()
1867 memcpy(rss_ctx->vnic.rss_hash_key, rxfh->key, in bnxt_modify_rss()
1870 memcpy(bp->rss_hash_key, rxfh->key, HW_HASH_KEY_SIZE); in bnxt_modify_rss()
1871 bp->rss_hash_key_updated = true; in bnxt_modify_rss()
1874 if (rxfh->indir) { in bnxt_modify_rss()
1875 u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(bp->dev); in bnxt_modify_rss()
1876 u32 *indir_tbl = bp->rss_indir_tbl; in bnxt_modify_rss()
1881 indir_tbl[i] = rxfh->indir[i]; in bnxt_modify_rss()
1882 pad = bp->rss_indir_tbl_entries - tbl_size; in bnxt_modify_rss()
1892 if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) { in bnxt_rxfh_context_check()
1894 return -EOPNOTSUPP; in bnxt_rxfh_context_check()
1899 return -EOPNOTSUPP; in bnxt_rxfh_context_check()
1902 if (!netif_running(bp->dev)) { in bnxt_rxfh_context_check()
1904 return -EAGAIN; in bnxt_rxfh_context_check()
1924 if (bp->num_rss_ctx >= BNXT_MAX_ETH_RSS_CTX) { in bnxt_create_rxfh_context()
1927 return -EINVAL; in bnxt_create_rxfh_context()
1932 return -ENOMEM; in bnxt_create_rxfh_context()
1937 bp->num_rss_ctx++; in bnxt_create_rxfh_context()
1939 vnic = &rss_ctx->vnic; in bnxt_create_rxfh_context()
1940 vnic->rss_ctx = ctx; in bnxt_create_rxfh_context()
1941 vnic->flags |= BNXT_VNIC_RSSCTX_FLAG; in bnxt_create_rxfh_context()
1942 vnic->vnic_id = BNXT_VNIC_ID_INVALID; in bnxt_create_rxfh_context()
1949 ctx->hfunc = ETH_RSS_HASH_TOP; in bnxt_create_rxfh_context()
1950 memcpy(vnic->rss_hash_key, bp->rss_hash_key, HW_HASH_KEY_SIZE); in bnxt_create_rxfh_context()
1952 bp->rss_hash_key, HW_HASH_KEY_SIZE); in bnxt_create_rxfh_context()
1954 rc = bnxt_hwrm_vnic_alloc(bp, vnic, 0, bp->rx_nr_rings); in bnxt_create_rxfh_context()
1960 rc = bnxt_hwrm_vnic_set_tpa(bp, vnic, bp->flags & BNXT_FLAG_TPA); in bnxt_create_rxfh_context()
1973 rss_ctx->index = rxfh->rss_context; in bnxt_create_rxfh_context()
1997 return bnxt_hwrm_vnic_rss_cfg_p5(bp, &rss_ctx->vnic); in bnxt_modify_rxfh_context()
2021 if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) in bnxt_set_rxfh()
2022 return -EOPNOTSUPP; in bnxt_set_rxfh()
2026 if (netif_running(bp->dev)) { in bnxt_set_rxfh()
2038 strscpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); in bnxt_get_drvinfo()
2039 strscpy(info->fw_version, bp->fw_ver_str, sizeof(info->fw_version)); in bnxt_get_drvinfo()
2040 strscpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info)); in bnxt_get_drvinfo()
2041 info->n_stats = bnxt_get_num_stats(bp); in bnxt_get_drvinfo()
2042 info->testinfo_len = bp->num_tests; in bnxt_get_drvinfo()
2044 info->eedump_len = 0; in bnxt_get_drvinfo()
2046 info->regdump_len = 0; in bnxt_get_drvinfo()
2055 return -EOPNOTSUPP; in bnxt_get_regs_len()
2059 if (bp->fw_cap & BNXT_FW_CAP_PCIE_STATS_SUPPORTED) in bnxt_get_regs_len()
2074 regs->version = 0; in bnxt_get_regs()
2075 if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_REG_ACCESS_RESTRICTED)) in bnxt_get_regs()
2078 if (!(bp->fw_cap & BNXT_FW_CAP_PCIE_STATS_SUPPORTED)) in bnxt_get_regs()
2091 regs->version = 1; in bnxt_get_regs()
2093 req->pcie_stat_size = cpu_to_le16(sizeof(*hw_pcie_stats)); in bnxt_get_regs()
2094 req->pcie_stat_host_addr = cpu_to_le64(hw_pcie_stats_addr); in bnxt_get_regs()
2111 wol->supported = 0; in bnxt_get_wol()
2112 wol->wolopts = 0; in bnxt_get_wol()
2113 memset(&wol->sopass, 0, sizeof(wol->sopass)); in bnxt_get_wol()
2114 if (bp->flags & BNXT_FLAG_WOL_CAP) { in bnxt_get_wol()
2115 wol->supported = WAKE_MAGIC; in bnxt_get_wol()
2116 if (bp->wol) in bnxt_get_wol()
2117 wol->wolopts = WAKE_MAGIC; in bnxt_get_wol()
2125 if (wol->wolopts & ~WAKE_MAGIC) in bnxt_set_wol()
2126 return -EINVAL; in bnxt_set_wol()
2128 if (wol->wolopts & WAKE_MAGIC) { in bnxt_set_wol()
2129 if (!(bp->flags & BNXT_FLAG_WOL_CAP)) in bnxt_set_wol()
2130 return -EINVAL; in bnxt_set_wol()
2131 if (!bp->wol) { in bnxt_set_wol()
2133 return -EBUSY; in bnxt_set_wol()
2134 bp->wol = 1; in bnxt_set_wol()
2137 if (bp->wol) { in bnxt_set_wol()
2139 return -EBUSY; in bnxt_set_wol()
2140 bp->wol = 0; in bnxt_set_wol()
2235 switch (link_info->media_type) { in bnxt_get_media()
2241 if (link_info->phy_type < ARRAY_SIZE(bnxt_phy_types)) in bnxt_get_media()
2242 return bnxt_phy_types[link_info->phy_type]; in bnxt_get_media()
2393 #define BNXT_LINK_MODE_UNKNOWN -1
2403 if (link_info->phy_link_status != BNXT_LINK_LINK) in bnxt_get_link_mode()
2407 if (BNXT_AUTO_MODE(link_info->auto_mode)) { in bnxt_get_link_mode()
2408 speed = bnxt_fw_speed_idx(link_info->link_speed); in bnxt_get_link_mode()
2409 sig_mode = link_info->active_fec_sig_mode & in bnxt_get_link_mode()
2412 speed = bnxt_fw_speed_idx(link_info->req_link_speed); in bnxt_get_link_mode()
2413 sig_mode = link_info->req_signal_mode; in bnxt_get_link_mode()
2428 if (~link_info->duplex & BNXT_LINK_DUPLEX_FULL) in bnxt_get_link_mode()
2432 if (~link_info->duplex & BNXT_LINK_DUPLEX_FULL) in bnxt_get_link_mode()
2447 if (!(bp->phy_flags & BNXT_PHY_FL_NO_PAUSE)) { in bnxt_get_ethtool_modes()
2449 lk_ksettings->link_modes.supported); in bnxt_get_ethtool_modes()
2451 lk_ksettings->link_modes.supported); in bnxt_get_ethtool_modes()
2454 if (link_info->support_auto_speeds || link_info->support_auto_speeds2 || in bnxt_get_ethtool_modes()
2455 link_info->support_pam4_auto_speeds) in bnxt_get_ethtool_modes()
2457 lk_ksettings->link_modes.supported); in bnxt_get_ethtool_modes()
2459 if (~link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_get_ethtool_modes()
2462 if (link_info->auto_pause_setting & BNXT_LINK_PAUSE_RX) in bnxt_get_ethtool_modes()
2464 lk_ksettings->link_modes.advertising); in bnxt_get_ethtool_modes()
2465 if (hweight8(link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) == 1) in bnxt_get_ethtool_modes()
2467 lk_ksettings->link_modes.advertising); in bnxt_get_ethtool_modes()
2468 if (link_info->lp_pause & BNXT_LINK_PAUSE_RX) in bnxt_get_ethtool_modes()
2470 lk_ksettings->link_modes.lp_advertising); in bnxt_get_ethtool_modes()
2471 if (hweight8(link_info->lp_pause & BNXT_LINK_PAUSE_BOTH) == 1) in bnxt_get_ethtool_modes()
2473 lk_ksettings->link_modes.lp_advertising); in bnxt_get_ethtool_modes()
2484 [__BNXT_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
2491 [__BNXT_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
2501 [__BNXT_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
2604 u16 phy_flags = bp->phy_flags; in bnxt_get_all_ethtool_support_speeds()
2607 sp_nrz = link_info->support_speeds2; in bnxt_get_all_ethtool_support_speeds()
2608 sp_pam4 = link_info->support_speeds2; in bnxt_get_all_ethtool_support_speeds()
2609 sp_pam4_112 = link_info->support_speeds2; in bnxt_get_all_ethtool_support_speeds()
2611 sp_nrz = link_info->support_speeds; in bnxt_get_all_ethtool_support_speeds()
2612 sp_pam4 = link_info->support_pam4_speeds; in bnxt_get_all_ethtool_support_speeds()
2615 lk_ksettings->link_modes.supported); in bnxt_get_all_ethtool_support_speeds()
2617 lk_ksettings->link_modes.supported); in bnxt_get_all_ethtool_support_speeds()
2619 phy_flags, lk_ksettings->link_modes.supported); in bnxt_get_all_ethtool_support_speeds()
2629 u16 phy_flags = bp->phy_flags; in bnxt_get_all_ethtool_adv_speeds()
2631 sp_nrz = link_info->advertising; in bnxt_get_all_ethtool_adv_speeds()
2633 sp_pam4 = link_info->advertising; in bnxt_get_all_ethtool_adv_speeds()
2634 sp_pam4_112 = link_info->advertising; in bnxt_get_all_ethtool_adv_speeds()
2636 sp_pam4 = link_info->advertising_pam4; in bnxt_get_all_ethtool_adv_speeds()
2639 lk_ksettings->link_modes.advertising); in bnxt_get_all_ethtool_adv_speeds()
2641 lk_ksettings->link_modes.advertising); in bnxt_get_all_ethtool_adv_speeds()
2643 phy_flags, lk_ksettings->link_modes.advertising); in bnxt_get_all_ethtool_adv_speeds()
2652 u16 phy_flags = bp->phy_flags; in bnxt_get_all_ethtool_lp_speeds()
2654 bnxt_get_ethtool_speeds(link_info->lp_auto_link_speeds, media, in bnxt_get_all_ethtool_lp_speeds()
2656 lk_ksettings->link_modes.lp_advertising); in bnxt_get_all_ethtool_lp_speeds()
2657 bnxt_get_ethtool_speeds(link_info->lp_auto_pam4_link_speeds, media, in bnxt_get_all_ethtool_lp_speeds()
2659 lk_ksettings->link_modes.lp_advertising); in bnxt_get_all_ethtool_lp_speeds()
2697 adv = &link_info->advertising; in bnxt_set_ethtool_speeds()
2698 if (bp->phy_flags & BNXT_PHY_FL_SPEEDS2) { in bnxt_set_ethtool_speeds()
2699 adv_pam4 = &link_info->advertising; in bnxt_set_ethtool_speeds()
2700 adv_pam4_112 = &link_info->advertising; in bnxt_set_ethtool_speeds()
2705 adv_pam4 = &link_info->advertising_pam4; in bnxt_set_ethtool_speeds()
2731 u16 fec_cfg = link_info->fec_cfg; in bnxt_fw_to_ethtool_advertised_fec()
2735 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
2740 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
2743 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
2746 lk_ksettings->link_modes.advertising); in bnxt_fw_to_ethtool_advertised_fec()
2752 u16 fec_cfg = link_info->fec_cfg; in bnxt_fw_to_ethtool_support_fec()
2756 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
2761 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
2764 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
2767 lk_ksettings->link_modes.supported); in bnxt_fw_to_ethtool_support_fec()
2810 struct ethtool_link_settings *base = &lk_ksettings->base; in bnxt_get_default_speeds()
2812 if (link_info->link_state == BNXT_LINK_STATE_UP) { in bnxt_get_default_speeds()
2813 base->speed = bnxt_fw_to_ethtool_speed(link_info->link_speed); in bnxt_get_default_speeds()
2814 base->duplex = DUPLEX_HALF; in bnxt_get_default_speeds()
2815 if (link_info->duplex & BNXT_LINK_DUPLEX_FULL) in bnxt_get_default_speeds()
2816 base->duplex = DUPLEX_FULL; in bnxt_get_default_speeds()
2817 lk_ksettings->lanes = link_info->active_lanes; in bnxt_get_default_speeds()
2818 } else if (!link_info->autoneg) { in bnxt_get_default_speeds()
2819 base->speed = bnxt_fw_to_ethtool_speed(link_info->req_link_speed); in bnxt_get_default_speeds()
2820 base->duplex = DUPLEX_HALF; in bnxt_get_default_speeds()
2821 if (link_info->req_duplex == BNXT_LINK_DUPLEX_FULL) in bnxt_get_default_speeds()
2822 base->duplex = DUPLEX_FULL; in bnxt_get_default_speeds()
2829 struct ethtool_link_settings *base = &lk_ksettings->base; in bnxt_get_link_ksettings()
2836 ethtool_link_ksettings_zero_link_mode(lk_ksettings, advertising); in bnxt_get_link_ksettings()
2838 base->duplex = DUPLEX_UNKNOWN; in bnxt_get_link_ksettings()
2839 base->speed = SPEED_UNKNOWN; in bnxt_get_link_ksettings()
2840 link_info = &bp->link_info; in bnxt_get_link_ksettings()
2842 mutex_lock(&bp->link_lock); in bnxt_get_link_ksettings()
2853 if (link_info->autoneg) { in bnxt_get_link_ksettings()
2856 lk_ksettings->link_modes.advertising); in bnxt_get_link_ksettings()
2857 base->autoneg = AUTONEG_ENABLE; in bnxt_get_link_ksettings()
2859 if (link_info->phy_link_status == BNXT_LINK_LINK) in bnxt_get_link_ksettings()
2863 base->autoneg = AUTONEG_DISABLE; in bnxt_get_link_ksettings()
2866 base->port = PORT_NONE; in bnxt_get_link_ksettings()
2868 base->port = PORT_TP; in bnxt_get_link_ksettings()
2870 lk_ksettings->link_modes.supported); in bnxt_get_link_ksettings()
2872 lk_ksettings->link_modes.advertising); in bnxt_get_link_ksettings()
2875 lk_ksettings->link_modes.supported); in bnxt_get_link_ksettings()
2877 lk_ksettings->link_modes.advertising); in bnxt_get_link_ksettings()
2880 lk_ksettings->link_modes.supported); in bnxt_get_link_ksettings()
2882 lk_ksettings->link_modes.advertising); in bnxt_get_link_ksettings()
2885 base->port = PORT_DA; in bnxt_get_link_ksettings()
2887 base->port = PORT_FIBRE; in bnxt_get_link_ksettings()
2889 base->phy_address = link_info->phy_addr; in bnxt_get_link_ksettings()
2890 mutex_unlock(&bp->link_lock); in bnxt_get_link_ksettings()
2899 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_force_link_speed()
2900 u16 support_pam4_spds = link_info->support_pam4_speeds; in bnxt_force_link_speed()
2901 u16 support_spds2 = link_info->support_speeds2; in bnxt_force_link_speed()
2902 u16 support_spds = link_info->support_speeds; in bnxt_force_link_speed()
3010 return -EINVAL; in bnxt_force_link_speed()
3015 return -EINVAL; in bnxt_force_link_speed()
3018 if (link_info->req_link_speed == fw_speed && in bnxt_force_link_speed()
3019 link_info->req_signal_mode == sig_mode && in bnxt_force_link_speed()
3020 link_info->autoneg == 0) in bnxt_force_link_speed()
3021 return -EALREADY; in bnxt_force_link_speed()
3023 link_info->req_link_speed = fw_speed; in bnxt_force_link_speed()
3024 link_info->req_signal_mode = sig_mode; in bnxt_force_link_speed()
3025 link_info->req_duplex = BNXT_LINK_DUPLEX_FULL; in bnxt_force_link_speed()
3026 link_info->autoneg = 0; in bnxt_force_link_speed()
3027 link_info->advertising = 0; in bnxt_force_link_speed()
3028 link_info->advertising_pam4 = 0; in bnxt_force_link_speed()
3058 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_set_link_ksettings()
3059 const struct ethtool_link_settings *base = &lk_ksettings->base; in bnxt_set_link_ksettings()
3065 return -EOPNOTSUPP; in bnxt_set_link_ksettings()
3067 mutex_lock(&bp->link_lock); in bnxt_set_link_ksettings()
3068 if (base->autoneg == AUTONEG_ENABLE) { in bnxt_set_link_ksettings()
3070 lk_ksettings->link_modes.advertising); in bnxt_set_link_ksettings()
3071 link_info->autoneg |= BNXT_AUTONEG_SPEED; in bnxt_set_link_ksettings()
3072 if (!link_info->advertising && !link_info->advertising_pam4) { in bnxt_set_link_ksettings()
3073 link_info->advertising = link_info->support_auto_speeds; in bnxt_set_link_ksettings()
3074 link_info->advertising_pam4 = in bnxt_set_link_ksettings()
3075 link_info->support_pam4_auto_speeds; in bnxt_set_link_ksettings()
3080 if (!(bp->phy_flags & BNXT_PHY_FL_NO_PAUSE)) in bnxt_set_link_ksettings()
3083 u8 phy_type = link_info->phy_type; in bnxt_set_link_ksettings()
3087 link_info->media_type == PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP) { in bnxt_set_link_ksettings()
3088 netdev_err(dev, "10GBase-T devices must autoneg\n"); in bnxt_set_link_ksettings()
3089 rc = -EINVAL; in bnxt_set_link_ksettings()
3092 if (base->duplex == DUPLEX_HALF) { in bnxt_set_link_ksettings()
3094 rc = -EINVAL; in bnxt_set_link_ksettings()
3097 speed = base->speed; in bnxt_set_link_ksettings()
3098 lanes = lk_ksettings->lanes; in bnxt_set_link_ksettings()
3101 if (rc == -EALREADY) in bnxt_set_link_ksettings()
3111 mutex_unlock(&bp->link_lock); in bnxt_set_link_ksettings()
3123 link_info = &bp->link_info; in bnxt_get_fecparam()
3124 fec_cfg = link_info->fec_cfg; in bnxt_get_fecparam()
3125 active_fec = link_info->active_fec_sig_mode & in bnxt_get_fecparam()
3128 fec->fec = ETHTOOL_FEC_NONE; in bnxt_get_fecparam()
3129 fec->active_fec = ETHTOOL_FEC_NONE; in bnxt_get_fecparam()
3133 fec->fec |= ETHTOOL_FEC_AUTO; in bnxt_get_fecparam()
3135 fec->fec |= ETHTOOL_FEC_BASER; in bnxt_get_fecparam()
3137 fec->fec |= ETHTOOL_FEC_RS; in bnxt_get_fecparam()
3139 fec->fec |= ETHTOOL_FEC_LLRS; in bnxt_get_fecparam()
3143 fec->active_fec |= ETHTOOL_FEC_BASER; in bnxt_get_fecparam()
3148 fec->active_fec |= ETHTOOL_FEC_RS; in bnxt_get_fecparam()
3152 fec->active_fec |= ETHTOOL_FEC_LLRS; in bnxt_get_fecparam()
3155 fec->active_fec |= ETHTOOL_FEC_OFF; in bnxt_get_fecparam()
3167 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_get_fec_stats()
3170 rx = bp->rx_port_stats_ext.sw_stats; in bnxt_get_fec_stats()
3171 fec_stats->corrected_bits.total = in bnxt_get_fec_stats()
3174 if (bp->fw_rx_stats_ext_size <= BNXT_RX_STATS_EXT_NUM_LEGACY) in bnxt_get_fec_stats()
3177 fec_stats->corrected_blocks.total = in bnxt_get_fec_stats()
3179 fec_stats->uncorrectable_blocks.total = in bnxt_get_fec_stats()
3203 u32 new_cfg, fec = fecparam->fec; in bnxt_set_fecparam()
3207 link_info = &bp->link_info; in bnxt_set_fecparam()
3208 fec_cfg = link_info->fec_cfg; in bnxt_set_fecparam()
3210 return -EOPNOTSUPP; in bnxt_set_fecparam()
3221 return -EINVAL; in bnxt_set_fecparam()
3224 if (!link_info->autoneg) in bnxt_set_fecparam()
3225 return -EINVAL; in bnxt_set_fecparam()
3235 req->flags = cpu_to_le32(new_cfg | PORT_PHY_CFG_REQ_FLAGS_RESET_PHY); in bnxt_set_fecparam()
3239 mutex_lock(&bp->link_lock); in bnxt_set_fecparam()
3241 mutex_unlock(&bp->link_lock); in bnxt_set_fecparam()
3250 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_get_pauseparam()
3254 epause->autoneg = !!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL); in bnxt_get_pauseparam()
3255 epause->rx_pause = !!(link_info->req_flow_ctrl & BNXT_LINK_PAUSE_RX); in bnxt_get_pauseparam()
3256 epause->tx_pause = !!(link_info->req_flow_ctrl & BNXT_LINK_PAUSE_TX); in bnxt_get_pauseparam()
3265 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_pause_stats()
3268 rx = bp->port_stats.sw_stats; in bnxt_get_pause_stats()
3269 tx = bp->port_stats.sw_stats + BNXT_TX_PORT_STATS_BYTE_OFFSET / 8; in bnxt_get_pause_stats()
3271 epstat->rx_pause_frames = BNXT_GET_RX_PORT_STATS64(rx, rx_pause_frames); in bnxt_get_pause_stats()
3272 epstat->tx_pause_frames = BNXT_GET_TX_PORT_STATS64(tx, tx_pause_frames); in bnxt_get_pause_stats()
3280 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_set_pauseparam()
3282 if (!BNXT_PHY_CFG_ABLE(bp) || (bp->phy_flags & BNXT_PHY_FL_NO_PAUSE)) in bnxt_set_pauseparam()
3283 return -EOPNOTSUPP; in bnxt_set_pauseparam()
3285 mutex_lock(&bp->link_lock); in bnxt_set_pauseparam()
3286 if (epause->autoneg) { in bnxt_set_pauseparam()
3287 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_set_pauseparam()
3288 rc = -EINVAL; in bnxt_set_pauseparam()
3292 link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL; in bnxt_set_pauseparam()
3293 link_info->req_flow_ctrl = 0; in bnxt_set_pauseparam()
3298 if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) in bnxt_set_pauseparam()
3299 link_info->force_link_chng = true; in bnxt_set_pauseparam()
3300 link_info->autoneg &= ~BNXT_AUTONEG_FLOW_CTRL; in bnxt_set_pauseparam()
3301 link_info->req_flow_ctrl = 0; in bnxt_set_pauseparam()
3303 if (epause->rx_pause) in bnxt_set_pauseparam()
3304 link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_RX; in bnxt_set_pauseparam()
3306 if (epause->tx_pause) in bnxt_set_pauseparam()
3307 link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_TX; in bnxt_set_pauseparam()
3313 mutex_unlock(&bp->link_lock); in bnxt_set_pauseparam()
3333 return -EOPNOTSUPP; in bnxt_hwrm_nvm_get_dev_info()
3349 netdev_info(bp->dev, "PF does not have admin privileges to flash or reset the device\n"); in bnxt_print_admin_err()
3376 return -ENOMEM; in bnxt_flash_nvram()
3379 req->dir_data_length = cpu_to_le32(data_len); in bnxt_flash_nvram()
3382 req->host_src_addr = cpu_to_le64(dma_handle); in bnxt_flash_nvram()
3385 hwrm_req_timeout(bp, req, bp->hwrm_cmd_max_timeout); in bnxt_flash_nvram()
3386 req->dir_type = cpu_to_le16(dir_type); in bnxt_flash_nvram()
3387 req->dir_ordinal = cpu_to_le16(dir_ordinal); in bnxt_flash_nvram()
3388 req->dir_ext = cpu_to_le16(dir_ext); in bnxt_flash_nvram()
3389 req->dir_attr = cpu_to_le16(dir_attr); in bnxt_flash_nvram()
3390 req->dir_item_length = cpu_to_le32(dir_item_len); in bnxt_flash_nvram()
3393 if (rc == -EACCES) in bnxt_flash_nvram()
3406 netdev_warn(bp->dev, "Reset denied by firmware, it may be inhibited by remote driver"); in bnxt_hwrm_firmware_reset()
3407 return -EPERM; in bnxt_hwrm_firmware_reset()
3414 req->embedded_proc_type = proc_type; in bnxt_hwrm_firmware_reset()
3415 req->selfrst_status = self_reset; in bnxt_hwrm_firmware_reset()
3416 req->flags = flags; in bnxt_hwrm_firmware_reset()
3422 if (rc == -EACCES) in bnxt_hwrm_firmware_reset()
3434 /* TODO: Address self-reset of APE/KONG/BONO/TANG or ungraceful reset */ in bnxt_firmware_reset()
3441 /* Self-reset ChiMP upon next PCIe reset: */ in bnxt_firmware_reset()
3447 /* Self-reset APE upon next PCIe reset: */ in bnxt_firmware_reset()
3459 return -EINVAL; in bnxt_firmware_reset()
3470 if (bp->fw_cap & BNXT_FW_CAP_HOT_RESET) in bnxt_firmware_reset_chip()
3526 return -EINVAL; in bnxt_flash_firmware()
3531 return -EINVAL; in bnxt_flash_firmware()
3533 if (header->signature != cpu_to_le32(BNXT_FIRMWARE_BIN_SIGNATURE)) { in bnxt_flash_firmware()
3535 le32_to_cpu(header->signature)); in bnxt_flash_firmware()
3536 return -EINVAL; in bnxt_flash_firmware()
3538 if (header->code_type != code_type) { in bnxt_flash_firmware()
3540 code_type, header->code_type); in bnxt_flash_firmware()
3541 return -EINVAL; in bnxt_flash_firmware()
3543 if (header->device != DEVICE_CUMULUS_FAMILY) { in bnxt_flash_firmware()
3545 DEVICE_CUMULUS_FAMILY, header->device); in bnxt_flash_firmware()
3546 return -EINVAL; in bnxt_flash_firmware()
3549 stored_crc = le32_to_cpu(*(__le32 *)(fw_data + fw_size - in bnxt_flash_firmware()
3551 calculated_crc = ~crc32(~0, fw_data, fw_size - sizeof(stored_crc)); in bnxt_flash_firmware()
3556 return -EINVAL; in bnxt_flash_firmware()
3579 return -EINVAL; in bnxt_flash_microcode()
3581 trailer = (struct bnxt_ucode_trailer *)(fw_data + (fw_size - in bnxt_flash_microcode()
3583 if (trailer->sig != cpu_to_le32(BNXT_UCODE_TRAILER_SIGNATURE)) { in bnxt_flash_microcode()
3585 le32_to_cpu(trailer->sig)); in bnxt_flash_microcode()
3586 return -EINVAL; in bnxt_flash_microcode()
3588 if (le16_to_cpu(trailer->dir_type) != dir_type) { in bnxt_flash_microcode()
3590 dir_type, le16_to_cpu(trailer->dir_type)); in bnxt_flash_microcode()
3591 return -EINVAL; in bnxt_flash_microcode()
3593 if (le16_to_cpu(trailer->trailer_length) < in bnxt_flash_microcode()
3596 le16_to_cpu(trailer->trailer_length)); in bnxt_flash_microcode()
3597 return -EINVAL; in bnxt_flash_microcode()
3601 stored_crc = le32_to_cpu(*(__le32 *)(fw_data + fw_size - in bnxt_flash_microcode()
3603 calculated_crc = ~crc32(~0, fw_data, fw_size - sizeof(stored_crc)); in bnxt_flash_microcode()
3609 return -EINVAL; in bnxt_flash_microcode()
3666 rc = request_firmware(&fw, filename, &dev->dev); in bnxt_flash_firmware_from_file()
3673 rc = bnxt_flash_firmware(dev, dir_type, fw->data, fw->size); in bnxt_flash_firmware_from_file()
3675 rc = bnxt_flash_microcode(dev, dir_type, fw->data, fw->size); in bnxt_flash_firmware_from_file()
3678 0, 0, 0, fw->data, fw->size); in bnxt_flash_firmware_from_file()
3691 #define MSG_ANTI_ROLLBACK_ERR "HWRM_NVM_INSTALL_UPDATE failure due to Anti-rollback detected"
3705 return -EINVAL; in nvm_update_err_to_stderr()
3720 return -ENOPKG; in nvm_update_err_to_stderr()
3723 return -EPERM; in nvm_update_err_to_stderr()
3730 return -EOPNOTSUPP; in nvm_update_err_to_stderr()
3733 return -EIO; in nvm_update_err_to_stderr()
3784 rc = bnxt_resize_update_entry(dev, fw->size, extack); in bnxt_flash_package_from_fw_obj()
3797 modify_len = roundup_pow_of_two(fw->size); in bnxt_flash_package_from_fw_obj()
3808 return -ENOMEM; in bnxt_flash_package_from_fw_obj()
3817 hwrm_req_timeout(bp, modify, bp->hwrm_cmd_max_timeout); in bnxt_flash_package_from_fw_obj()
3818 hwrm_req_timeout(bp, install, bp->hwrm_cmd_max_timeout); in bnxt_flash_package_from_fw_obj()
3821 modify->host_src_addr = cpu_to_le64(dma_handle); in bnxt_flash_package_from_fw_obj()
3826 install->install_type = cpu_to_le32(install_type); in bnxt_flash_package_from_fw_obj()
3839 if (fw->size > item_len) { in bnxt_flash_package_from_fw_obj()
3841 rc = -EFBIG; in bnxt_flash_package_from_fw_obj()
3845 modify->dir_idx = cpu_to_le16(index); in bnxt_flash_package_from_fw_obj()
3847 if (fw->size > modify_len) in bnxt_flash_package_from_fw_obj()
3848 modify->flags = BNXT_NVM_MORE_FLAG; in bnxt_flash_package_from_fw_obj()
3849 while (copied < fw->size) { in bnxt_flash_package_from_fw_obj()
3850 u32 balance = fw->size - copied; in bnxt_flash_package_from_fw_obj()
3855 modify->flags |= BNXT_NVM_LAST_FLAG; in bnxt_flash_package_from_fw_obj()
3857 memcpy(kmem, fw->data + copied, len); in bnxt_flash_package_from_fw_obj()
3858 modify->len = cpu_to_le32(len); in bnxt_flash_package_from_fw_obj()
3859 modify->offset = cpu_to_le32(copied); in bnxt_flash_package_from_fw_obj()
3877 cmd_err = ((struct hwrm_err_output *)resp)->cmd_err; in bnxt_flash_package_from_fw_obj()
3882 rc = -EALREADY; in bnxt_flash_package_from_fw_obj()
3885 install->flags = in bnxt_flash_package_from_fw_obj()
3892 cmd_err = ((struct hwrm_err_output *)resp)->cmd_err; in bnxt_flash_package_from_fw_obj()
3899 install->flags = 0; in bnxt_flash_package_from_fw_obj()
3900 rc = bnxt_flash_nvram(bp->dev, in bnxt_flash_package_from_fw_obj()
3917 if (resp->result) { in bnxt_flash_package_from_fw_obj()
3919 (s8)resp->result, (int)resp->problem_item); in bnxt_flash_package_from_fw_obj()
3920 rc = nvm_update_err_to_stderr(dev, resp->result, extack); in bnxt_flash_package_from_fw_obj()
3922 if (rc == -EACCES) in bnxt_flash_package_from_fw_obj()
3933 rc = request_firmware(&fw, filename, &dev->dev); in bnxt_flash_package_from_file()
3952 return -EINVAL; in bnxt_flash_device()
3955 if (flash->region == ETHTOOL_FLASH_ALL_REGIONS || in bnxt_flash_device()
3956 flash->region > 0xffff) in bnxt_flash_device()
3957 return bnxt_flash_package_from_file(dev, flash->data, in bnxt_flash_device()
3958 flash->region, NULL); in bnxt_flash_device()
3960 return bnxt_flash_firmware_from_file(dev, flash->region, flash->data); in bnxt_flash_device()
3977 *entries = le32_to_cpu(output->entries); in nvm_get_dir_info()
3978 *length = le32_to_cpu(output->entry_length); in nvm_get_dir_info()
3991 /* The -1 return value allows the entire 32-bit range of offsets to be in bnxt_get_eeprom_len()
3992 * passed via the ethtool command-line utility. in bnxt_get_eeprom_len()
3994 return -1; in bnxt_get_eeprom_len()
4013 return -EIO; in bnxt_get_nvram_directory()
4017 return -EINVAL; in bnxt_get_nvram_directory()
4021 len -= 2; in bnxt_get_nvram_directory()
4032 return -ENOMEM; in bnxt_get_nvram_directory()
4034 req->host_dest_addr = cpu_to_le64(dma_handle); in bnxt_get_nvram_directory()
4054 return -EINVAL; in bnxt_get_nvram_item()
4063 return -ENOMEM; in bnxt_get_nvram_item()
4066 req->host_dest_addr = cpu_to_le64(dma_handle); in bnxt_get_nvram_item()
4067 req->dir_idx = cpu_to_le16(index); in bnxt_get_nvram_item()
4068 req->offset = cpu_to_le32(offset); in bnxt_get_nvram_item()
4069 req->len = cpu_to_le32(length); in bnxt_get_nvram_item()
4092 req->enables = 0; in bnxt_find_nvram_item()
4093 req->dir_idx = 0; in bnxt_find_nvram_item()
4094 req->dir_type = cpu_to_le16(type); in bnxt_find_nvram_item()
4095 req->dir_ordinal = cpu_to_le16(ordinal); in bnxt_find_nvram_item()
4096 req->dir_ext = cpu_to_le16(ext); in bnxt_find_nvram_item()
4097 req->opt_ordinal = NVM_FIND_DIR_ENTRY_REQ_OPT_ORDINAL_EQ; in bnxt_find_nvram_item()
4102 *index = le16_to_cpu(output->dir_idx); in bnxt_find_nvram_item()
4104 *item_length = le32_to_cpu(output->dir_item_length); in bnxt_find_nvram_item()
4106 *data_length = le32_to_cpu(output->dir_data_length); in bnxt_find_nvram_item()
4121 /* null-terminate the log data (removing last '\n'): */ in bnxt_parse_pkglog()
4122 data[datalen - 1] = 0; in bnxt_parse_pkglog()
4162 dev_err(&bp->pdev->dev, "Unable to allocate memory for pkg version, length = %u\n", in bnxt_get_pkginfo()
4164 return -ENOMEM; in bnxt_get_pkginfo()
4176 rc = -ENOENT; in bnxt_get_pkginfo()
4187 char buf[FW_VER_STR_LEN - 5]; in bnxt_get_pkgver()
4191 len = strlen(bp->fw_ver_str); in bnxt_get_pkgver()
4192 snprintf(bp->fw_ver_str + len, FW_VER_STR_LEN - len, in bnxt_get_pkgver()
4204 if (eeprom->offset == 0) /* special offset value to get directory */ in bnxt_get_eeprom()
4205 return bnxt_get_nvram_directory(dev, eeprom->len, data); in bnxt_get_eeprom()
4207 index = eeprom->offset >> 24; in bnxt_get_eeprom()
4208 offset = eeprom->offset & 0xffffff; in bnxt_get_eeprom()
4212 return -EINVAL; in bnxt_get_eeprom()
4215 return bnxt_get_nvram_item(dev, index - 1, offset, eeprom->len, data); in bnxt_get_eeprom()
4228 req->dir_idx = cpu_to_le16(index); in bnxt_erase_nvram_directory()
4242 return -EINVAL; in bnxt_set_eeprom()
4245 type = eeprom->magic >> 16; in bnxt_set_eeprom()
4248 index = eeprom->magic & 0xff; in bnxt_set_eeprom()
4249 dir_op = eeprom->magic >> 8; in bnxt_set_eeprom()
4251 return -EINVAL; in bnxt_set_eeprom()
4254 if (eeprom->offset != ~eeprom->magic) in bnxt_set_eeprom()
4255 return -EINVAL; in bnxt_set_eeprom()
4256 return bnxt_erase_nvram_directory(dev, index - 1); in bnxt_set_eeprom()
4258 return -EINVAL; in bnxt_set_eeprom()
4262 /* Create or re-write an NVM item: */ in bnxt_set_eeprom()
4264 return -EOPNOTSUPP; in bnxt_set_eeprom()
4265 ext = eeprom->magic & 0xffff; in bnxt_set_eeprom()
4266 ordinal = eeprom->offset >> 16; in bnxt_set_eeprom()
4267 attr = eeprom->offset & 0xffff; in bnxt_set_eeprom()
4270 eeprom->len); in bnxt_set_eeprom()
4275 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising); in bnxt_set_eee()
4278 struct ethtool_keee *eee = &bp->eee; in bnxt_set_eee()
4279 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_set_eee()
4283 return -EOPNOTSUPP; in bnxt_set_eee()
4285 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_set_eee()
4286 return -EOPNOTSUPP; in bnxt_set_eee()
4288 mutex_lock(&bp->link_lock); in bnxt_set_eee()
4289 _bnxt_fw_to_linkmode(advertising, link_info->advertising); in bnxt_set_eee()
4290 if (!edata->eee_enabled) in bnxt_set_eee()
4293 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) { in bnxt_set_eee()
4295 rc = -EINVAL; in bnxt_set_eee()
4298 if (edata->tx_lpi_enabled) { in bnxt_set_eee()
4299 if (bp->lpi_tmr_hi && (edata->tx_lpi_timer > bp->lpi_tmr_hi || in bnxt_set_eee()
4300 edata->tx_lpi_timer < bp->lpi_tmr_lo)) { in bnxt_set_eee()
4302 bp->lpi_tmr_lo, bp->lpi_tmr_hi); in bnxt_set_eee()
4303 rc = -EINVAL; in bnxt_set_eee()
4305 } else if (!bp->lpi_tmr_hi) { in bnxt_set_eee()
4306 edata->tx_lpi_timer = eee->tx_lpi_timer; in bnxt_set_eee()
4309 if (linkmode_empty(edata->advertised)) { in bnxt_set_eee()
4310 linkmode_and(edata->advertised, advertising, eee->supported); in bnxt_set_eee()
4311 } else if (linkmode_andnot(tmp, edata->advertised, advertising)) { in bnxt_set_eee()
4313 rc = -EINVAL; in bnxt_set_eee()
4317 linkmode_copy(eee->advertised, edata->advertised); in bnxt_set_eee()
4318 eee->tx_lpi_enabled = edata->tx_lpi_enabled; in bnxt_set_eee()
4319 eee->tx_lpi_timer = edata->tx_lpi_timer; in bnxt_set_eee()
4321 eee->eee_enabled = edata->eee_enabled; in bnxt_set_eee()
4327 mutex_unlock(&bp->link_lock); in bnxt_set_eee()
4335 if (!(bp->phy_flags & BNXT_PHY_FL_EEE_CAP)) in bnxt_get_eee()
4336 return -EOPNOTSUPP; in bnxt_get_eee()
4338 *edata = bp->eee; in bnxt_get_eee()
4339 if (!bp->eee.eee_enabled) { in bnxt_get_eee()
4341 * by default when it is re-enabled. in bnxt_get_eee()
4343 linkmode_zero(edata->advertised); in bnxt_get_eee()
4344 edata->tx_lpi_enabled = 0; in bnxt_get_eee()
4347 if (!bp->eee.eee_active) in bnxt_get_eee()
4348 linkmode_zero(edata->lp_advertised); in bnxt_get_eee()
4360 switch (tuna->id) { in bnxt_set_tunable()
4364 return -ERANGE; in bnxt_set_tunable()
4365 if (rx_copybreak != bp->rx_copybreak) { in bnxt_set_tunable()
4367 return -EBUSY; in bnxt_set_tunable()
4368 bp->rx_copybreak = rx_copybreak; in bnxt_set_tunable()
4372 return -EOPNOTSUPP; in bnxt_set_tunable()
4381 switch (tuna->id) { in bnxt_get_tunable()
4383 *(u32 *)data = bp->rx_copybreak; in bnxt_get_tunable()
4386 return -EOPNOTSUPP; in bnxt_get_tunable()
4406 req->i2c_slave_addr = i2c_addr; in bnxt_read_sfp_module_eeprom_info()
4407 req->page_number = cpu_to_le16(page_number); in bnxt_read_sfp_module_eeprom_info()
4408 req->port_id = cpu_to_le16(bp->pf.port_id); in bnxt_read_sfp_module_eeprom_info()
4413 data_length -= xfer_size; in bnxt_read_sfp_module_eeprom_info()
4414 req->page_offset = cpu_to_le16(start_addr + byte_offset); in bnxt_read_sfp_module_eeprom_info()
4415 req->data_length = xfer_size; in bnxt_read_sfp_module_eeprom_info()
4416 req->enables = in bnxt_read_sfp_module_eeprom_info()
4425 memcpy(buf + byte_offset, output->data, xfer_size); in bnxt_read_sfp_module_eeprom_info()
4441 return -EPERM; in bnxt_get_module_info()
4445 * if it is of type 10GBase-T in bnxt_get_module_info()
4447 if (bp->link_info.module_status > in bnxt_get_module_info()
4449 return -EOPNOTSUPP; in bnxt_get_module_info()
4452 if (bp->hwrm_spec_code < 0x10202) in bnxt_get_module_info()
4453 return -EOPNOTSUPP; in bnxt_get_module_info()
4464 modinfo->type = ETH_MODULE_SFF_8472; in bnxt_get_module_info()
4465 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; in bnxt_get_module_info()
4467 modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN; in bnxt_get_module_info()
4471 modinfo->type = ETH_MODULE_SFF_8436; in bnxt_get_module_info()
4472 modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN; in bnxt_get_module_info()
4475 modinfo->type = ETH_MODULE_SFF_8636; in bnxt_get_module_info()
4476 modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN; in bnxt_get_module_info()
4479 rc = -EOPNOTSUPP; in bnxt_get_module_info()
4491 u16 start = eeprom->offset, length = eeprom->len; in bnxt_get_module_eeprom()
4495 return -EPERM; in bnxt_get_module_eeprom()
4497 memset(data, 0, eeprom->len); in bnxt_get_module_eeprom()
4501 if (start + eeprom->len > ETH_MODULE_SFF_8436_LEN) in bnxt_get_module_eeprom()
4502 length = ETH_MODULE_SFF_8436_LEN - start; in bnxt_get_module_eeprom()
4509 length = eeprom->len - length; in bnxt_get_module_eeprom()
4514 start -= ETH_MODULE_SFF_8436_LEN; in bnxt_get_module_eeprom()
4523 if (bp->link_info.module_status <= in bnxt_get_module_status()
4527 switch (bp->link_info.module_status) { in bnxt_get_module_status()
4541 return -EINVAL; in bnxt_get_module_status()
4554 return -EPERM; in bnxt_get_module_eeprom_by_page()
4561 if (bp->hwrm_spec_code < 0x10202) { in bnxt_get_module_eeprom_by_page()
4563 return -EINVAL; in bnxt_get_module_eeprom_by_page()
4566 if (page_data->bank && !(bp->phy_flags & BNXT_PHY_FL_BANK_SEL)) { in bnxt_get_module_eeprom_by_page()
4568 return -EINVAL; in bnxt_get_module_eeprom_by_page()
4571 rc = bnxt_read_sfp_module_eeprom_info(bp, page_data->i2c_address << 1, in bnxt_get_module_eeprom_by_page()
4572 page_data->page, page_data->bank, in bnxt_get_module_eeprom_by_page()
4573 page_data->offset, in bnxt_get_module_eeprom_by_page()
4574 page_data->length, in bnxt_get_module_eeprom_by_page()
4575 page_data->data); in bnxt_get_module_eeprom_by_page()
4580 return page_data->length; in bnxt_get_module_eeprom_by_page()
4588 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_nway_reset()
4591 return -EOPNOTSUPP; in bnxt_nway_reset()
4593 if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) in bnxt_nway_reset()
4594 return -EINVAL; in bnxt_nway_reset()
4607 struct bnxt_pf_info *pf = &bp->pf; in bnxt_set_phys_id()
4613 if (!bp->num_leds || BNXT_VF(bp)) in bnxt_set_phys_id()
4614 return -EOPNOTSUPP; in bnxt_set_phys_id()
4623 return -EINVAL; in bnxt_set_phys_id()
4629 req->port_id = cpu_to_le16(pf->port_id); in bnxt_set_phys_id()
4630 req->num_leds = bp->num_leds; in bnxt_set_phys_id()
4631 led_cfg = (struct bnxt_led_cfg *)&req->led0_id; in bnxt_set_phys_id()
4632 for (i = 0; i < bp->num_leds; i++, led_cfg++) { in bnxt_set_phys_id()
4633 req->enables |= BNXT_LED_DFLT_ENABLES(i); in bnxt_set_phys_id()
4634 led_cfg->led_id = bp->leds[i].led_id; in bnxt_set_phys_id()
4635 led_cfg->led_state = led_state; in bnxt_set_phys_id()
4636 led_cfg->led_blink_on = duration; in bnxt_set_phys_id()
4637 led_cfg->led_blink_off = duration; in bnxt_set_phys_id()
4638 led_cfg->led_group_id = bp->leds[i].led_group_id; in bnxt_set_phys_id()
4652 req->cmpl_ring = cpu_to_le16(cmpl_ring); in bnxt_hwrm_selftest_irq()
4660 for (i = 0; i < bp->cp_nr_rings; i++) { in bnxt_test_irq()
4661 u16 cmpl_ring = bp->grp_info[i].cp_fw_ring_id; in bnxt_test_irq()
4680 req->enables = cpu_to_le32(PORT_MAC_CFG_REQ_ENABLES_LPBK); in bnxt_hwrm_mac_loopback()
4682 req->lpbk = PORT_MAC_CFG_REQ_LPBK_LOCAL; in bnxt_hwrm_mac_loopback()
4684 req->lpbk = PORT_MAC_CFG_REQ_LPBK_NONE; in bnxt_hwrm_mac_loopback()
4701 *force_speeds = le16_to_cpu(resp->supported_speeds_force_mode); in bnxt_query_force_speeds()
4710 struct bnxt_link_info *link_info = &bp->link_info; in bnxt_disable_an_for_lpbk()
4715 if (!link_info->autoneg || in bnxt_disable_an_for_lpbk()
4716 (bp->phy_flags & BNXT_PHY_FL_AN_PHY_LPBK)) in bnxt_disable_an_for_lpbk()
4725 fw_speed = bp->link_info.link_speed; in bnxt_disable_an_for_lpbk()
4735 req->force_link_speed = cpu_to_le16(fw_speed); in bnxt_disable_an_for_lpbk()
4736 req->flags |= cpu_to_le32(PORT_PHY_CFG_REQ_FLAGS_FORCE | in bnxt_disable_an_for_lpbk()
4739 req->flags = 0; in bnxt_disable_an_for_lpbk()
4740 req->force_link_speed = cpu_to_le16(0); in bnxt_disable_an_for_lpbk()
4759 req->lpbk = PORT_PHY_CFG_REQ_LPBK_EXTERNAL; in bnxt_hwrm_phy_loopback()
4761 req->lpbk = PORT_PHY_CFG_REQ_LPBK_LOCAL; in bnxt_hwrm_phy_loopback()
4763 req->lpbk = PORT_PHY_CFG_REQ_LPBK_NONE; in bnxt_hwrm_phy_loopback()
4765 req->enables = cpu_to_le32(PORT_PHY_CFG_REQ_ENABLES_LPBK); in bnxt_hwrm_phy_loopback()
4774 struct bnxt_napi *bnapi = cpr->bnapi; in bnxt_rx_loopback()
4783 rxr = bnapi->rx_ring; in bnxt_rx_loopback()
4786 &cpr->cp_desc_ring[CP_RING(cp_cons)][CP_IDX(cp_cons)]; in bnxt_rx_loopback()
4787 cons = rxcmp->rx_cmp_opaque; in bnxt_rx_loopback()
4788 rx_buf = &rxr->rx_buf_ring[cons]; in bnxt_rx_loopback()
4789 data = rx_buf->data_ptr; in bnxt_rx_loopback()
4790 len = le32_to_cpu(rxcmp->rx_cmp_len_flags_type) >> RX_CMP_LEN_SHIFT; in bnxt_rx_loopback()
4792 return -EIO; in bnxt_rx_loopback()
4794 if (!ether_addr_equal(data + i, bnapi->bp->dev->dev_addr)) in bnxt_rx_loopback()
4795 return -EIO; in bnxt_rx_loopback()
4799 return -EIO; in bnxt_rx_loopback()
4808 int rc = -EIO; in bnxt_poll_loopback()
4813 raw_cons = cpr->cp_raw_cons; in bnxt_poll_loopback()
4816 txcmp = &cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]; in bnxt_poll_loopback()
4836 cpr->cp_raw_cons = raw_cons; in bnxt_poll_loopback()
4842 struct bnxt_tx_ring_info *txr = &bp->tx_ring[0]; in bnxt_run_loopback()
4843 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[0]; in bnxt_run_loopback()
4851 cpr = &rxr->bnapi->cp_ring; in bnxt_run_loopback()
4852 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) in bnxt_run_loopback()
4853 cpr = rxr->rx_cpr; in bnxt_run_loopback()
4854 pkt_size = min(bp->dev->mtu + ETH_HLEN, max(BNXT_DEFAULT_RX_COPYBREAK, in bnxt_run_loopback()
4855 bp->rx_copybreak)); in bnxt_run_loopback()
4856 skb = netdev_alloc_skb(bp->dev, pkt_size); in bnxt_run_loopback()
4858 return -ENOMEM; in bnxt_run_loopback()
4860 ether_addr_copy(&data[i], bp->dev->dev_addr); in bnxt_run_loopback()
4862 ether_addr_copy(&data[i], bp->dev->dev_addr); in bnxt_run_loopback()
4867 map = dma_map_single(&bp->pdev->dev, skb->data, pkt_size, in bnxt_run_loopback()
4869 if (dma_mapping_error(&bp->pdev->dev, map)) { in bnxt_run_loopback()
4871 return -EIO; in bnxt_run_loopback()
4878 bnxt_db_write(bp, &txr->tx_db, txr->tx_prod); in bnxt_run_loopback()
4881 dma_unmap_single(&bp->pdev->dev, map, pkt_size, DMA_TO_DEVICE); in bnxt_run_loopback()
4896 hwrm_req_timeout(bp, req, bp->test_info->timeout); in bnxt_run_fw_tests()
4897 req->flags = test_mask; in bnxt_run_fw_tests()
4901 *test_results = resp->test_success; in bnxt_run_fw_tests()
4907 #define BNXT_MACLPBK_TEST_IDX (bp->num_tests - BNXT_DRV_TESTS)
4922 if (!bp->num_tests || !BNXT_PF(bp)) in bnxt_self_test()
4925 if (etest->flags & ETH_TEST_FL_OFFLINE && in bnxt_self_test()
4926 bnxt_ulp_registered(bp->edev)) { in bnxt_self_test()
4927 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4932 memset(buf, 0, sizeof(u64) * bp->num_tests); in bnxt_self_test()
4934 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4938 if ((etest->flags & ETH_TEST_FL_EXTERNAL_LB) && in bnxt_self_test()
4939 (bp->phy_flags & BNXT_PHY_FL_EXT_LPBK)) in bnxt_self_test()
4942 if (etest->flags & ETH_TEST_FL_OFFLINE) { in bnxt_self_test()
4943 if (bp->pf.active_vfs || !BNXT_SINGLE_PF(bp)) { in bnxt_self_test()
4944 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4951 for (i = 0; i < bp->num_tests - BNXT_DRV_TESTS; i++) { in bnxt_self_test()
4954 if (!(bp->test_info->offline_mask & bit_val)) in bnxt_self_test()
4967 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4971 if (bp->mac_flags & BNXT_MAC_FL_NO_MAC_LPBK) in bnxt_self_test()
4977 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4984 if (bp->phy_flags & BNXT_PHY_FL_NO_PHY_LPBK) in bnxt_self_test()
4990 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
4996 etest->flags |= ETH_TEST_FL_EXTERNAL_LB_DONE; in bnxt_self_test()
5000 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
5010 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
5012 for (i = 0; i < bp->num_tests - BNXT_DRV_TESTS; i++) { in bnxt_self_test()
5017 etest->flags |= ETH_TEST_FL_FAILED; in bnxt_self_test()
5029 return -EINVAL; in bnxt_reset()
5033 return -EOPNOTSUPP; in bnxt_reset()
5036 if (pci_vfs_assigned(bp->pdev) && in bnxt_reset()
5037 !(bp->fw_cap & BNXT_FW_CAP_HOT_RESET)) { in bnxt_reset()
5040 return -EBUSY; in bnxt_reset()
5045 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_reset()
5048 if (!(bp->fw_cap & BNXT_FW_CAP_HOT_RESET)) in bnxt_reset()
5053 return -EOPNOTSUPP; /* only request, fail hard */ in bnxt_reset()
5059 if (bp->hwrm_spec_code >= 0x10803) { in bnxt_reset()
5066 return -EOPNOTSUPP; /* only request, fail hard */ in bnxt_reset()
5080 if (dump->flag > BNXT_DUMP_DRIVER) { in bnxt_set_dump()
5082 return -EINVAL; in bnxt_set_dump()
5085 if (dump->flag == BNXT_DUMP_CRASH) { in bnxt_set_dump()
5086 if (bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_SOC_DDR && in bnxt_set_dump()
5090 return -EOPNOTSUPP; in bnxt_set_dump()
5091 } else if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR)) { in bnxt_set_dump()
5093 return -EOPNOTSUPP; in bnxt_set_dump()
5097 bp->dump_flag = dump->flag; in bnxt_set_dump()
5105 if (bp->hwrm_spec_code < 0x10801) in bnxt_get_dump_flag()
5106 return -EOPNOTSUPP; in bnxt_get_dump_flag()
5108 dump->version = bp->ver_resp.hwrm_fw_maj_8b << 24 | in bnxt_get_dump_flag()
5109 bp->ver_resp.hwrm_fw_min_8b << 16 | in bnxt_get_dump_flag()
5110 bp->ver_resp.hwrm_fw_bld_8b << 8 | in bnxt_get_dump_flag()
5111 bp->ver_resp.hwrm_fw_rsvd_8b; in bnxt_get_dump_flag()
5113 dump->flag = bp->dump_flag; in bnxt_get_dump_flag()
5114 dump->len = bnxt_get_coredump_length(bp, bp->dump_flag); in bnxt_get_dump_flag()
5123 if (bp->hwrm_spec_code < 0x10801) in bnxt_get_dump_data()
5124 return -EOPNOTSUPP; in bnxt_get_dump_data()
5126 memset(buf, 0, dump->len); in bnxt_get_dump_data()
5128 dump->flag = bp->dump_flag; in bnxt_get_dump_data()
5129 return bnxt_get_coredump(bp, dump->flag, buf, &dump->len); in bnxt_get_dump_data()
5138 ptp = bp->ptp_cfg; in bnxt_get_ts_info()
5139 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE; in bnxt_get_ts_info()
5144 info->so_timestamping |= SOF_TIMESTAMPING_TX_HARDWARE | in bnxt_get_ts_info()
5147 if (ptp->ptp_clock) in bnxt_get_ts_info()
5148 info->phc_index = ptp_clock_index(ptp->ptp_clock); in bnxt_get_ts_info()
5150 info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); in bnxt_get_ts_info()
5152 info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | in bnxt_get_ts_info()
5156 if (bp->fw_cap & BNXT_FW_CAP_RX_ALL_PKT_TS) in bnxt_get_ts_info()
5157 info->rx_filters |= (1 << HWTSTAMP_FILTER_ALL); in bnxt_get_ts_info()
5166 struct net_device *dev = bp->dev; in bnxt_ethtool_init()
5169 if (!(bp->fw_cap & BNXT_FW_CAP_PKG_VER)) in bnxt_ethtool_init()
5172 bp->num_tests = 0; in bnxt_ethtool_init()
5173 if (bp->hwrm_spec_code < 0x10704 || !BNXT_PF(bp)) in bnxt_ethtool_init()
5176 test_info = bp->test_info; in bnxt_ethtool_init()
5178 test_info = kzalloc(sizeof(*bp->test_info), GFP_KERNEL); in bnxt_ethtool_init()
5181 bp->test_info = test_info; in bnxt_ethtool_init()
5192 bp->num_tests = resp->num_tests + BNXT_DRV_TESTS; in bnxt_ethtool_init()
5193 if (bp->num_tests > BNXT_MAX_TEST) in bnxt_ethtool_init()
5194 bp->num_tests = BNXT_MAX_TEST; in bnxt_ethtool_init()
5196 test_info->offline_mask = resp->offline_tests; in bnxt_ethtool_init()
5197 test_info->timeout = le16_to_cpu(resp->test_timeout); in bnxt_ethtool_init()
5198 if (!test_info->timeout) in bnxt_ethtool_init()
5199 test_info->timeout = HWRM_CMD_TIMEOUT; in bnxt_ethtool_init()
5200 for (i = 0; i < bp->num_tests; i++) { in bnxt_ethtool_init()
5201 char *str = test_info->string[i]; in bnxt_ethtool_init()
5202 char *fw_str = resp->test_name[i]; in bnxt_ethtool_init()
5214 fw_str, test_info->offline_mask & (1 << i) ? in bnxt_ethtool_init()
5229 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_get_eth_phy_stats()
5232 rx = bp->rx_port_stats_ext.sw_stats; in bnxt_get_eth_phy_stats()
5233 phy_stats->SymbolErrorDuringCarrier = in bnxt_get_eth_phy_stats()
5243 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_eth_mac_stats()
5246 rx = bp->port_stats.sw_stats; in bnxt_get_eth_mac_stats()
5247 tx = bp->port_stats.sw_stats + BNXT_TX_PORT_STATS_BYTE_OFFSET / 8; in bnxt_get_eth_mac_stats()
5249 mac_stats->FramesReceivedOK = in bnxt_get_eth_mac_stats()
5251 mac_stats->FramesTransmittedOK = in bnxt_get_eth_mac_stats()
5253 mac_stats->FrameCheckSequenceErrors = in bnxt_get_eth_mac_stats()
5255 mac_stats->AlignmentErrors = in bnxt_get_eth_mac_stats()
5257 mac_stats->OutOfRangeLengthField = in bnxt_get_eth_mac_stats()
5267 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_eth_ctrl_stats()
5270 rx = bp->port_stats.sw_stats; in bnxt_get_eth_ctrl_stats()
5271 ctrl_stats->MACControlFramesReceived = in bnxt_get_eth_ctrl_stats()
5296 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS)) in bnxt_get_rmon_stats()
5299 rx = bp->port_stats.sw_stats; in bnxt_get_rmon_stats()
5300 tx = bp->port_stats.sw_stats + BNXT_TX_PORT_STATS_BYTE_OFFSET / 8; in bnxt_get_rmon_stats()
5302 rmon_stats->jabbers = in bnxt_get_rmon_stats()
5304 rmon_stats->oversize_pkts = in bnxt_get_rmon_stats()
5306 rmon_stats->undersize_pkts = in bnxt_get_rmon_stats()
5309 rmon_stats->hist[0] = BNXT_GET_RX_PORT_STATS64(rx, rx_64b_frames); in bnxt_get_rmon_stats()
5310 rmon_stats->hist[1] = BNXT_GET_RX_PORT_STATS64(rx, rx_65b_127b_frames); in bnxt_get_rmon_stats()
5311 rmon_stats->hist[2] = BNXT_GET_RX_PORT_STATS64(rx, rx_128b_255b_frames); in bnxt_get_rmon_stats()
5312 rmon_stats->hist[3] = BNXT_GET_RX_PORT_STATS64(rx, rx_256b_511b_frames); in bnxt_get_rmon_stats()
5313 rmon_stats->hist[4] = in bnxt_get_rmon_stats()
5315 rmon_stats->hist[5] = in bnxt_get_rmon_stats()
5317 rmon_stats->hist[6] = in bnxt_get_rmon_stats()
5319 rmon_stats->hist[7] = in bnxt_get_rmon_stats()
5321 rmon_stats->hist[8] = in bnxt_get_rmon_stats()
5323 rmon_stats->hist[9] = in bnxt_get_rmon_stats()
5326 rmon_stats->hist_tx[0] = in bnxt_get_rmon_stats()
5328 rmon_stats->hist_tx[1] = in bnxt_get_rmon_stats()
5330 rmon_stats->hist_tx[2] = in bnxt_get_rmon_stats()
5332 rmon_stats->hist_tx[3] = in bnxt_get_rmon_stats()
5334 rmon_stats->hist_tx[4] = in bnxt_get_rmon_stats()
5336 rmon_stats->hist_tx[5] = in bnxt_get_rmon_stats()
5338 rmon_stats->hist_tx[6] = in bnxt_get_rmon_stats()
5340 rmon_stats->hist_tx[7] = in bnxt_get_rmon_stats()
5342 rmon_stats->hist_tx[8] = in bnxt_get_rmon_stats()
5344 rmon_stats->hist_tx[9] = in bnxt_get_rmon_stats()
5354 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_get_ptp_stats()
5357 ts_stats->pkts = ptp->stats.ts_pkts; in bnxt_get_ptp_stats()
5358 ts_stats->lost = ptp->stats.ts_lost; in bnxt_get_ptp_stats()
5359 ts_stats->err = atomic64_read(&ptp->stats.ts_err); in bnxt_get_ptp_stats()
5369 if (BNXT_VF(bp) || !(bp->flags & BNXT_FLAG_PORT_STATS_EXT)) in bnxt_get_link_ext_stats()
5372 rx = bp->rx_port_stats_ext.sw_stats; in bnxt_get_link_ext_stats()
5373 stats->link_down_events = in bnxt_get_link_ext_stats()
5379 kfree(bp->test_info); in bnxt_ethtool_free()
5380 bp->test_info = NULL; in bnxt_ethtool_free()