Lines Matching +full:rx +full:- +full:tx +full:- +full:swap
1 // SPDX-License-Identifier: GPL-2.0
48 struct fbnic_dev *fbd = fbn->fbd; in fbnic_get_drvinfo()
50 fbnic_get_fw_ver_commit_str(fbd, drvinfo->fw_version, in fbnic_get_drvinfo()
51 sizeof(drvinfo->fw_version)); in fbnic_get_drvinfo()
58 return fbnic_csr_regs_len(fbn->fbd) * sizeof(u32); in fbnic_get_regs_len()
66 fbnic_csr_get_regs(fbn->fbd, data, ®s->version); in fbnic_get_regs()
77 memset(clone->tx, 0, sizeof(clone->tx)); in fbnic_clone_create()
78 memset(clone->rx, 0, sizeof(clone->rx)); in fbnic_clone_create()
79 memset(clone->napi, 0, sizeof(clone->napi)); in fbnic_clone_create()
86 swap(clone->rcq_size, orig->rcq_size); in fbnic_clone_swap_cfg()
87 swap(clone->hpq_size, orig->hpq_size); in fbnic_clone_swap_cfg()
88 swap(clone->ppq_size, orig->ppq_size); in fbnic_clone_swap_cfg()
89 swap(clone->txq_size, orig->txq_size); in fbnic_clone_swap_cfg()
90 swap(clone->num_rx_queues, orig->num_rx_queues); in fbnic_clone_swap_cfg()
91 swap(clone->num_tx_queues, orig->num_tx_queues); in fbnic_clone_swap_cfg()
92 swap(clone->num_napi, orig->num_napi); in fbnic_clone_swap_cfg()
100 for (i = 0; i < nv->txt_count; i++) { in fbnic_aggregate_vector_counters()
101 fbnic_aggregate_ring_tx_counters(fbn, &nv->qt[i].sub0); in fbnic_aggregate_vector_counters()
102 fbnic_aggregate_ring_tx_counters(fbn, &nv->qt[i].sub1); in fbnic_aggregate_vector_counters()
103 fbnic_aggregate_ring_tx_counters(fbn, &nv->qt[i].cmpl); in fbnic_aggregate_vector_counters()
106 for (j = 0; j < nv->rxt_count; j++, i++) { in fbnic_aggregate_vector_counters()
107 fbnic_aggregate_ring_rx_counters(fbn, &nv->qt[i].sub0); in fbnic_aggregate_vector_counters()
108 fbnic_aggregate_ring_rx_counters(fbn, &nv->qt[i].sub1); in fbnic_aggregate_vector_counters()
109 fbnic_aggregate_ring_rx_counters(fbn, &nv->qt[i].cmpl); in fbnic_aggregate_vector_counters()
116 struct fbnic_dev *fbd = orig->fbd; in fbnic_clone_swap()
119 for (i = 0; i < max(clone->num_napi, orig->num_napi); i++) in fbnic_clone_swap()
121 for (i = 0; i < orig->num_napi; i++) in fbnic_clone_swap()
122 fbnic_aggregate_vector_counters(orig, orig->napi[i]); in fbnic_clone_swap()
126 for (i = 0; i < ARRAY_SIZE(orig->napi); i++) in fbnic_clone_swap()
127 swap(clone->napi[i], orig->napi[i]); in fbnic_clone_swap()
128 for (i = 0; i < ARRAY_SIZE(orig->tx); i++) in fbnic_clone_swap()
129 swap(clone->tx[i], orig->tx[i]); in fbnic_clone_swap()
130 for (i = 0; i < ARRAY_SIZE(orig->rx); i++) in fbnic_clone_swap()
131 swap(clone->rx[i], orig->rx[i]); in fbnic_clone_swap()
146 ec->tx_coalesce_usecs = fbn->tx_usecs; in fbnic_get_coalesce()
147 ec->rx_coalesce_usecs = fbn->rx_usecs; in fbnic_get_coalesce()
148 ec->rx_max_coalesced_frames = fbn->rx_max_frames; in fbnic_get_coalesce()
161 if (ec->rx_coalesce_usecs > FIELD_MAX(FBNIC_INTR_CQ_REARM_RCQ_TIMEOUT)) { in fbnic_set_coalesce()
163 return -EINVAL; in fbnic_set_coalesce()
165 if (ec->tx_coalesce_usecs > FIELD_MAX(FBNIC_INTR_CQ_REARM_TCQ_TIMEOUT)) { in fbnic_set_coalesce()
167 return -EINVAL; in fbnic_set_coalesce()
169 if (ec->rx_max_coalesced_frames > in fbnic_set_coalesce()
173 return -EINVAL; in fbnic_set_coalesce()
176 fbn->tx_usecs = ec->tx_coalesce_usecs; in fbnic_set_coalesce()
177 fbn->rx_usecs = ec->rx_coalesce_usecs; in fbnic_set_coalesce()
178 fbn->rx_max_frames = ec->rx_max_coalesced_frames; in fbnic_set_coalesce()
183 for (i = 0; i < fbn->num_napi; i++) { in fbnic_set_coalesce()
184 struct fbnic_napi_vector *nv = fbn->napi[i]; in fbnic_set_coalesce()
201 ring->rx_max_pending = FBNIC_QUEUE_SIZE_MAX; in fbnic_get_ringparam()
202 ring->rx_mini_max_pending = FBNIC_QUEUE_SIZE_MAX; in fbnic_get_ringparam()
203 ring->rx_jumbo_max_pending = FBNIC_QUEUE_SIZE_MAX; in fbnic_get_ringparam()
204 ring->tx_max_pending = FBNIC_QUEUE_SIZE_MAX; in fbnic_get_ringparam()
206 ring->rx_pending = fbn->rcq_size; in fbnic_get_ringparam()
207 ring->rx_mini_pending = fbn->hpq_size; in fbnic_get_ringparam()
208 ring->rx_jumbo_pending = fbn->ppq_size; in fbnic_get_ringparam()
209 ring->tx_pending = fbn->txq_size; in fbnic_get_ringparam()
215 fbn->rcq_size = ring->rx_pending; in fbnic_set_rings()
216 fbn->hpq_size = ring->rx_mini_pending; in fbnic_set_rings()
217 fbn->ppq_size = ring->rx_jumbo_pending; in fbnic_set_rings()
218 fbn->txq_size = ring->tx_pending; in fbnic_set_rings()
231 ring->rx_pending = roundup_pow_of_two(ring->rx_pending); in fbnic_set_ringparam()
232 ring->rx_mini_pending = roundup_pow_of_two(ring->rx_mini_pending); in fbnic_set_ringparam()
233 ring->rx_jumbo_pending = roundup_pow_of_two(ring->rx_jumbo_pending); in fbnic_set_ringparam()
234 ring->tx_pending = roundup_pow_of_two(ring->tx_pending); in fbnic_set_ringparam()
238 * Rx queue size of 128 and BDQs smaller than 64 are likely suboptimal in fbnic_set_ringparam()
241 if (ring->rx_pending < max(FBNIC_QUEUE_SIZE_MIN, FBNIC_RX_DESC_MIN) || in fbnic_set_ringparam()
242 ring->rx_mini_pending < FBNIC_QUEUE_SIZE_MIN || in fbnic_set_ringparam()
243 ring->rx_jumbo_pending < FBNIC_QUEUE_SIZE_MIN || in fbnic_set_ringparam()
244 ring->tx_pending < max(FBNIC_QUEUE_SIZE_MIN, FBNIC_TX_DESC_MIN)) { in fbnic_set_ringparam()
246 return -EINVAL; in fbnic_set_ringparam()
256 return -ENOMEM; in fbnic_set_ringparam()
269 err = fbnic_wait_all_queues_idle(fbn->fbd, true); in fbnic_set_ringparam()
320 fbnic_get_hw_stats(fbn->fbd); in fbnic_get_ethtool_stats()
324 data[i] = *(u64 *)((u8 *)&fbn->fbd->hw_stats + stat->offset); in fbnic_get_ethtool_stats()
334 return -EOPNOTSUPP; in fbnic_get_sset_count()
367 return -1; in fbnic_get_rss_hash_idx()
373 int hash_opt_idx = fbnic_get_rss_hash_idx(cmd->flow_type); in fbnic_get_rss_hash_opts()
376 return -EINVAL; in fbnic_get_rss_hash_opts()
379 cmd->data = fbn->rss_flow_hash[hash_opt_idx]; in fbnic_get_rss_hash_opts()
388 struct fbnic_dev *fbd = fbn->fbd; in fbnic_get_cls_rule_all()
392 cmd->data = FBNIC_RPC_ACT_TBL_NFC_ENTRIES; in fbnic_get_cls_rule_all()
398 act_tcam = &fbd->act_tcam[idx]; in fbnic_get_cls_rule_all()
399 if (act_tcam->state != FBNIC_TCAM_S_VALID) in fbnic_get_cls_rule_all()
403 if (cnt == cmd->rule_cnt) in fbnic_get_cls_rule_all()
404 return -EMSGSIZE; in fbnic_get_cls_rule_all()
418 struct fbnic_dev *fbd = fbn->fbd; in fbnic_get_cls_rule()
422 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; in fbnic_get_cls_rule()
424 if (fsp->location >= FBNIC_RPC_ACT_TBL_NFC_ENTRIES) in fbnic_get_cls_rule()
425 return -EINVAL; in fbnic_get_cls_rule()
427 idx = fsp->location + FBNIC_RPC_ACT_TBL_NFC_OFFSET; in fbnic_get_cls_rule()
428 act_tcam = &fbd->act_tcam[idx]; in fbnic_get_cls_rule()
430 if (act_tcam->state != FBNIC_TCAM_S_VALID) in fbnic_get_cls_rule()
431 return -EINVAL; in fbnic_get_cls_rule()
434 cmd->data = FBNIC_RPC_ACT_TBL_NFC_ENTRIES; in fbnic_get_cls_rule()
437 if (!(act_tcam->value.tcam[1] & FBNIC_RPC_TCAM_ACT1_IP_VALID)) { in fbnic_get_cls_rule()
438 fsp->flow_type = ETHER_FLOW; in fbnic_get_cls_rule()
440 act_tcam->mask.tcam[1])) { in fbnic_get_cls_rule()
444 act_tcam->value.tcam[1]); in fbnic_get_cls_rule()
445 mac_addr = &fbd->mac_addr[idx]; in fbnic_get_cls_rule()
447 ether_addr_copy(fsp->h_u.ether_spec.h_dest, in fbnic_get_cls_rule()
448 mac_addr->value.addr8); in fbnic_get_cls_rule()
449 eth_broadcast_addr(fsp->m_u.ether_spec.h_dest); in fbnic_get_cls_rule()
451 } else if (act_tcam->value.tcam[1] & in fbnic_get_cls_rule()
453 fsp->flow_type = IPV6_USER_FLOW; in fbnic_get_cls_rule()
454 fsp->h_u.usr_ip6_spec.l4_proto = IPPROTO_IPV6; in fbnic_get_cls_rule()
455 fsp->m_u.usr_ip6_spec.l4_proto = 0xff; in fbnic_get_cls_rule()
458 act_tcam->mask.tcam[0])) { in fbnic_get_cls_rule()
463 act_tcam->value.tcam[0]); in fbnic_get_cls_rule()
464 ip_addr = &fbd->ipo_src[idx]; in fbnic_get_cls_rule()
467 fsp->h_u.usr_ip6_spec.ip6src[i] = in fbnic_get_cls_rule()
468 ip_addr->value.s6_addr32[i]; in fbnic_get_cls_rule()
469 fsp->m_u.usr_ip6_spec.ip6src[i] = in fbnic_get_cls_rule()
470 ~ip_addr->mask.s6_addr32[i]; in fbnic_get_cls_rule()
475 act_tcam->mask.tcam[0])) { in fbnic_get_cls_rule()
480 act_tcam->value.tcam[0]); in fbnic_get_cls_rule()
481 ip_addr = &fbd->ipo_dst[idx]; in fbnic_get_cls_rule()
484 fsp->h_u.usr_ip6_spec.ip6dst[i] = in fbnic_get_cls_rule()
485 ip_addr->value.s6_addr32[i]; in fbnic_get_cls_rule()
486 fsp->m_u.usr_ip6_spec.ip6dst[i] = in fbnic_get_cls_rule()
487 ~ip_addr->mask.s6_addr32[i]; in fbnic_get_cls_rule()
490 } else if ((act_tcam->value.tcam[1] & FBNIC_RPC_TCAM_ACT1_IP_IS_V6)) { in fbnic_get_cls_rule()
491 if (act_tcam->value.tcam[1] & FBNIC_RPC_TCAM_ACT1_L4_VALID) { in fbnic_get_cls_rule()
492 if (act_tcam->value.tcam[1] & in fbnic_get_cls_rule()
494 fsp->flow_type = UDP_V6_FLOW; in fbnic_get_cls_rule()
496 fsp->flow_type = TCP_V6_FLOW; in fbnic_get_cls_rule()
497 fsp->h_u.tcp_ip6_spec.psrc = in fbnic_get_cls_rule()
498 cpu_to_be16(act_tcam->value.tcam[3]); in fbnic_get_cls_rule()
499 fsp->m_u.tcp_ip6_spec.psrc = in fbnic_get_cls_rule()
500 cpu_to_be16(~act_tcam->mask.tcam[3]); in fbnic_get_cls_rule()
501 fsp->h_u.tcp_ip6_spec.pdst = in fbnic_get_cls_rule()
502 cpu_to_be16(act_tcam->value.tcam[4]); in fbnic_get_cls_rule()
503 fsp->m_u.tcp_ip6_spec.pdst = in fbnic_get_cls_rule()
504 cpu_to_be16(~act_tcam->mask.tcam[4]); in fbnic_get_cls_rule()
506 fsp->flow_type = IPV6_USER_FLOW; in fbnic_get_cls_rule()
510 act_tcam->mask.tcam[0])) { in fbnic_get_cls_rule()
515 act_tcam->value.tcam[0]); in fbnic_get_cls_rule()
516 ip_addr = &fbd->ip_src[idx]; in fbnic_get_cls_rule()
519 fsp->h_u.usr_ip6_spec.ip6src[i] = in fbnic_get_cls_rule()
520 ip_addr->value.s6_addr32[i]; in fbnic_get_cls_rule()
521 fsp->m_u.usr_ip6_spec.ip6src[i] = in fbnic_get_cls_rule()
522 ~ip_addr->mask.s6_addr32[i]; in fbnic_get_cls_rule()
527 act_tcam->mask.tcam[0])) { in fbnic_get_cls_rule()
532 act_tcam->value.tcam[0]); in fbnic_get_cls_rule()
533 ip_addr = &fbd->ip_dst[idx]; in fbnic_get_cls_rule()
536 fsp->h_u.usr_ip6_spec.ip6dst[i] = in fbnic_get_cls_rule()
537 ip_addr->value.s6_addr32[i]; in fbnic_get_cls_rule()
538 fsp->m_u.usr_ip6_spec.ip6dst[i] = in fbnic_get_cls_rule()
539 ~ip_addr->mask.s6_addr32[i]; in fbnic_get_cls_rule()
543 if (act_tcam->value.tcam[1] & FBNIC_RPC_TCAM_ACT1_L4_VALID) { in fbnic_get_cls_rule()
544 if (act_tcam->value.tcam[1] & in fbnic_get_cls_rule()
546 fsp->flow_type = UDP_V4_FLOW; in fbnic_get_cls_rule()
548 fsp->flow_type = TCP_V4_FLOW; in fbnic_get_cls_rule()
549 fsp->h_u.tcp_ip4_spec.psrc = in fbnic_get_cls_rule()
550 cpu_to_be16(act_tcam->value.tcam[3]); in fbnic_get_cls_rule()
551 fsp->m_u.tcp_ip4_spec.psrc = in fbnic_get_cls_rule()
552 cpu_to_be16(~act_tcam->mask.tcam[3]); in fbnic_get_cls_rule()
553 fsp->h_u.tcp_ip4_spec.pdst = in fbnic_get_cls_rule()
554 cpu_to_be16(act_tcam->value.tcam[4]); in fbnic_get_cls_rule()
555 fsp->m_u.tcp_ip4_spec.pdst = in fbnic_get_cls_rule()
556 cpu_to_be16(~act_tcam->mask.tcam[4]); in fbnic_get_cls_rule()
558 fsp->flow_type = IPV4_USER_FLOW; in fbnic_get_cls_rule()
559 fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; in fbnic_get_cls_rule()
563 act_tcam->mask.tcam[0])) { in fbnic_get_cls_rule()
567 act_tcam->value.tcam[0]); in fbnic_get_cls_rule()
568 ip_addr = &fbd->ip_src[idx]; in fbnic_get_cls_rule()
570 fsp->h_u.usr_ip4_spec.ip4src = in fbnic_get_cls_rule()
571 ip_addr->value.s6_addr32[3]; in fbnic_get_cls_rule()
572 fsp->m_u.usr_ip4_spec.ip4src = in fbnic_get_cls_rule()
573 ~ip_addr->mask.s6_addr32[3]; in fbnic_get_cls_rule()
577 act_tcam->mask.tcam[0])) { in fbnic_get_cls_rule()
581 act_tcam->value.tcam[0]); in fbnic_get_cls_rule()
582 ip_addr = &fbd->ip_dst[idx]; in fbnic_get_cls_rule()
584 fsp->h_u.usr_ip4_spec.ip4dst = in fbnic_get_cls_rule()
585 ip_addr->value.s6_addr32[3]; in fbnic_get_cls_rule()
586 fsp->m_u.usr_ip4_spec.ip4dst = in fbnic_get_cls_rule()
587 ~ip_addr->mask.s6_addr32[3]; in fbnic_get_cls_rule()
592 if (act_tcam->dest & FBNIC_RPC_ACT_TBL0_DROP) in fbnic_get_cls_rule()
593 fsp->ring_cookie = RX_CLS_FLOW_DISC; in fbnic_get_cls_rule()
594 else if (act_tcam->dest & FBNIC_RPC_ACT_TBL0_Q_SEL) in fbnic_get_cls_rule()
595 fsp->ring_cookie = FIELD_GET(FBNIC_RPC_ACT_TBL0_Q_ID, in fbnic_get_cls_rule()
596 act_tcam->dest); in fbnic_get_cls_rule()
598 fsp->flow_type |= FLOW_RSS; in fbnic_get_cls_rule()
600 cmd->rss_context = FIELD_GET(FBNIC_RPC_ACT_TBL0_RSS_CTXT_ID, in fbnic_get_cls_rule()
601 act_tcam->dest); in fbnic_get_cls_rule()
610 int ret = -EOPNOTSUPP; in fbnic_get_rxnfc()
613 switch (cmd->cmd) { in fbnic_get_rxnfc()
615 cmd->data = fbn->num_rx_queues; in fbnic_get_rxnfc()
633 cmd->data |= special; in fbnic_get_rxnfc()
634 cmd->rule_cnt = ret; in fbnic_get_rxnfc()
655 hash_opt_idx = fbnic_get_rss_hash_idx(cmd->flow_type); in fbnic_set_rss_hash_opts()
657 return -EINVAL; in fbnic_set_rss_hash_opts()
660 if (cmd->data & ~FBNIC_L4_HASH_OPTIONS || in fbnic_set_rss_hash_opts()
662 cmd->data & ~FBNIC_L3_HASH_OPTIONS) || in fbnic_set_rss_hash_opts()
664 cmd->data & ~FBNIC_L2_HASH_OPTIONS)) in fbnic_set_rss_hash_opts()
665 return -EINVAL; in fbnic_set_rss_hash_opts()
667 fbn->rss_flow_hash[hash_opt_idx] = cmd->data; in fbnic_set_rss_hash_opts()
669 if (netif_running(fbn->netdev)) { in fbnic_set_rss_hash_opts()
670 fbnic_rss_reinit(fbn->fbd, fbn); in fbnic_set_rss_hash_opts()
671 fbnic_write_rules(fbn->fbd); in fbnic_set_rss_hash_opts()
681 for (i = FBNIC_RPC_ACT_TBL_NFC_ENTRIES; i--;) { in fbnic_cls_rule_any_loc()
684 if (fbd->act_tcam[idx].state != FBNIC_TCAM_S_VALID) in fbnic_cls_rule_any_loc()
688 return -ENOSPC; in fbnic_cls_rule_any_loc()
702 struct fbnic_dev *fbd = fbn->fbd; in fbnic_set_cls_rule_ins()
710 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; in fbnic_set_cls_rule_ins()
712 if (fsp->location != RX_CLS_LOC_ANY) in fbnic_set_cls_rule_ins()
713 return -EINVAL; in fbnic_set_cls_rule_ins()
718 if (fsp->ring_cookie == RX_CLS_FLOW_DISC) { in fbnic_set_cls_rule_ins()
720 } else if (fsp->flow_type & FLOW_RSS) { in fbnic_set_cls_rule_ins()
721 if (cmd->rss_context == 1) in fbnic_set_cls_rule_ins()
724 u32 ring_idx = ethtool_get_flow_spec_ring(fsp->ring_cookie); in fbnic_set_cls_rule_ins()
726 if (ring_idx >= fbn->num_rx_queues) in fbnic_set_cls_rule_ins()
727 return -EINVAL; in fbnic_set_cls_rule_ins()
734 act_tcam = &fbd->act_tcam[idx]; in fbnic_set_cls_rule_ins()
740 if (act_tcam->state != FBNIC_TCAM_S_DISABLED) in fbnic_set_cls_rule_ins()
741 return -EBUSY; in fbnic_set_cls_rule_ins()
743 flow_type = fsp->flow_type & ~(FLOW_EXT | FLOW_RSS); in fbnic_set_cls_rule_ins()
757 sport = be16_to_cpu(fsp->h_u.tcp_ip4_spec.psrc); in fbnic_set_cls_rule_ins()
758 sport_mask = ~be16_to_cpu(fsp->m_u.tcp_ip4_spec.psrc); in fbnic_set_cls_rule_ins()
759 dport = be16_to_cpu(fsp->h_u.tcp_ip4_spec.pdst); in fbnic_set_cls_rule_ins()
760 dport_mask = ~be16_to_cpu(fsp->m_u.tcp_ip4_spec.pdst); in fbnic_set_cls_rule_ins()
763 if (!fsp->m_u.usr_ip4_spec.proto) in fbnic_set_cls_rule_ins()
765 if (fsp->m_u.usr_ip4_spec.proto != 0xff) in fbnic_set_cls_rule_ins()
766 return -EINVAL; in fbnic_set_cls_rule_ins()
767 if (fsp->h_u.usr_ip4_spec.proto == IPPROTO_UDP) in fbnic_set_cls_rule_ins()
769 if (fsp->h_u.usr_ip4_spec.proto == IPPROTO_TCP) in fbnic_set_cls_rule_ins()
771 return -EINVAL; in fbnic_set_cls_rule_ins()
773 addr4 = (struct in_addr *)&fsp->h_u.usr_ip4_spec.ip4src; in fbnic_set_cls_rule_ins()
774 mask4 = (struct in_addr *)&fsp->m_u.usr_ip4_spec.ip4src; in fbnic_set_cls_rule_ins()
775 if (mask4->s_addr) { in fbnic_set_cls_rule_ins()
776 ip_src = __fbnic_ip4_sync(fbd, fbd->ip_src, in fbnic_set_cls_rule_ins()
779 return -ENOSPC; in fbnic_set_cls_rule_ins()
781 set_bit(idx, ip_src->act_tcam); in fbnic_set_cls_rule_ins()
784 ip_src - fbd->ip_src); in fbnic_set_cls_rule_ins()
789 addr4 = (struct in_addr *)&fsp->h_u.usr_ip4_spec.ip4dst; in fbnic_set_cls_rule_ins()
790 mask4 = (struct in_addr *)&fsp->m_u.usr_ip4_spec.ip4dst; in fbnic_set_cls_rule_ins()
791 if (mask4->s_addr) { in fbnic_set_cls_rule_ins()
792 ip_dst = __fbnic_ip4_sync(fbd, fbd->ip_dst, in fbnic_set_cls_rule_ins()
795 if (ip_src && ip_src->state == FBNIC_TCAM_S_ADD) in fbnic_set_cls_rule_ins()
797 return -ENOSPC; in fbnic_set_cls_rule_ins()
800 set_bit(idx, ip_dst->act_tcam); in fbnic_set_cls_rule_ins()
803 ip_dst - fbd->ip_dst); in fbnic_set_cls_rule_ins()
823 sport = be16_to_cpu(fsp->h_u.tcp_ip6_spec.psrc); in fbnic_set_cls_rule_ins()
824 sport_mask = ~be16_to_cpu(fsp->m_u.tcp_ip6_spec.psrc); in fbnic_set_cls_rule_ins()
825 dport = be16_to_cpu(fsp->h_u.tcp_ip6_spec.pdst); in fbnic_set_cls_rule_ins()
826 dport_mask = ~be16_to_cpu(fsp->m_u.tcp_ip6_spec.pdst); in fbnic_set_cls_rule_ins()
829 if (!fsp->m_u.usr_ip6_spec.l4_proto) in fbnic_set_cls_rule_ins()
832 if (fsp->m_u.usr_ip6_spec.l4_proto != 0xff) in fbnic_set_cls_rule_ins()
833 return -EINVAL; in fbnic_set_cls_rule_ins()
834 if (fsp->h_u.usr_ip6_spec.l4_proto == IPPROTO_UDP) in fbnic_set_cls_rule_ins()
836 if (fsp->h_u.usr_ip6_spec.l4_proto == IPPROTO_TCP) in fbnic_set_cls_rule_ins()
838 if (fsp->h_u.usr_ip6_spec.l4_proto != IPPROTO_IPV6) in fbnic_set_cls_rule_ins()
839 return -EINVAL; in fbnic_set_cls_rule_ins()
841 addr6 = (struct in6_addr *)fsp->h_u.usr_ip6_spec.ip6src; in fbnic_set_cls_rule_ins()
842 mask6 = (struct in6_addr *)fsp->m_u.usr_ip6_spec.ip6src; in fbnic_set_cls_rule_ins()
844 ip_src = __fbnic_ip6_sync(fbd, fbd->ipo_src, in fbnic_set_cls_rule_ins()
847 return -ENOSPC; in fbnic_set_cls_rule_ins()
849 set_bit(idx, ip_src->act_tcam); in fbnic_set_cls_rule_ins()
853 ip_src - fbd->ipo_src); in fbnic_set_cls_rule_ins()
859 addr6 = (struct in6_addr *)fsp->h_u.usr_ip6_spec.ip6dst; in fbnic_set_cls_rule_ins()
860 mask6 = (struct in6_addr *)fsp->m_u.usr_ip6_spec.ip6dst; in fbnic_set_cls_rule_ins()
862 ip_dst = __fbnic_ip6_sync(fbd, fbd->ipo_dst, in fbnic_set_cls_rule_ins()
865 if (ip_src && ip_src->state == FBNIC_TCAM_S_ADD) in fbnic_set_cls_rule_ins()
867 return -ENOSPC; in fbnic_set_cls_rule_ins()
870 set_bit(idx, ip_dst->act_tcam); in fbnic_set_cls_rule_ins()
874 ip_dst - fbd->ipo_dst); in fbnic_set_cls_rule_ins()
882 addr6 = (struct in6_addr *)fsp->h_u.usr_ip6_spec.ip6src; in fbnic_set_cls_rule_ins()
883 mask6 = (struct in6_addr *)fsp->m_u.usr_ip6_spec.ip6src; in fbnic_set_cls_rule_ins()
885 ip_src = __fbnic_ip6_sync(fbd, fbd->ip_src, in fbnic_set_cls_rule_ins()
888 return -ENOSPC; in fbnic_set_cls_rule_ins()
890 set_bit(idx, ip_src->act_tcam); in fbnic_set_cls_rule_ins()
893 ip_src - fbd->ip_src); in fbnic_set_cls_rule_ins()
898 addr6 = (struct in6_addr *)fsp->h_u.usr_ip6_spec.ip6dst; in fbnic_set_cls_rule_ins()
899 mask6 = (struct in6_addr *)fsp->m_u.usr_ip6_spec.ip6dst; in fbnic_set_cls_rule_ins()
901 ip_dst = __fbnic_ip6_sync(fbd, fbd->ip_dst, in fbnic_set_cls_rule_ins()
904 if (ip_src && ip_src->state == FBNIC_TCAM_S_ADD) in fbnic_set_cls_rule_ins()
906 return -ENOSPC; in fbnic_set_cls_rule_ins()
909 set_bit(idx, ip_dst->act_tcam); in fbnic_set_cls_rule_ins()
912 ip_dst - fbd->ip_dst); in fbnic_set_cls_rule_ins()
925 if (!is_zero_ether_addr(fsp->m_u.ether_spec.h_dest)) { in fbnic_set_cls_rule_ins()
926 u8 *addr = fsp->h_u.ether_spec.h_dest; in fbnic_set_cls_rule_ins()
927 u8 *mask = fsp->m_u.ether_spec.h_dest; in fbnic_set_cls_rule_ins()
931 return -EINVAL; in fbnic_set_cls_rule_ins()
937 return -EINVAL; in fbnic_set_cls_rule_ins()
945 return -ENOSPC; in fbnic_set_cls_rule_ins()
947 set_bit(idx, mac_addr->act_tcam); in fbnic_set_cls_rule_ins()
950 mac_addr - fbd->mac_addr); in fbnic_set_cls_rule_ins()
958 return -EINVAL; in fbnic_set_cls_rule_ins()
962 act_tcam->dest = dest; in fbnic_set_cls_rule_ins()
963 act_tcam->rss_en_mask = fbnic_flow_hash_2_rss_en_mask(fbn, hash_idx); in fbnic_set_cls_rule_ins()
966 act_tcam->value.tcam[0] = ip_value; in fbnic_set_cls_rule_ins()
967 act_tcam->mask.tcam[0] = ip_mask; in fbnic_set_cls_rule_ins()
970 act_tcam->value.tcam[1] = flow_value; in fbnic_set_cls_rule_ins()
971 act_tcam->mask.tcam[1] = flow_mask; in fbnic_set_cls_rule_ins()
974 act_tcam->value.tcam[2] = misc; in fbnic_set_cls_rule_ins()
975 act_tcam->mask.tcam[2] = misc_mask; in fbnic_set_cls_rule_ins()
978 act_tcam->value.tcam[3] = sport; in fbnic_set_cls_rule_ins()
979 act_tcam->mask.tcam[3] = sport_mask; in fbnic_set_cls_rule_ins()
980 act_tcam->value.tcam[4] = dport; in fbnic_set_cls_rule_ins()
981 act_tcam->mask.tcam[4] = dport_mask; in fbnic_set_cls_rule_ins()
984 act_tcam->mask.tcam[j] = 0xffff; in fbnic_set_cls_rule_ins()
986 act_tcam->state = FBNIC_TCAM_S_UPDATE; in fbnic_set_cls_rule_ins()
987 fsp->location = location; in fbnic_set_cls_rule_ins()
989 if (netif_running(fbn->netdev)) { in fbnic_set_cls_rule_ins()
1003 struct fbnic_dev *fbd = fbn->fbd; in fbnic_clear_nfc_macda()
1006 for (idx = ARRAY_SIZE(fbd->mac_addr); idx--;) in fbnic_clear_nfc_macda()
1007 __fbnic_xc_unsync(&fbd->mac_addr[idx], tcam_idx); in fbnic_clear_nfc_macda()
1010 if (netif_running(fbn->netdev)) in fbnic_clear_nfc_macda()
1017 struct fbnic_dev *fbd = fbn->fbd; in fbnic_clear_nfc_ip_addr()
1020 for (idx = ARRAY_SIZE(fbd->ip_src); idx--;) in fbnic_clear_nfc_ip_addr()
1021 __fbnic_ip_unsync(&fbd->ip_src[idx], tcam_idx); in fbnic_clear_nfc_ip_addr()
1022 for (idx = ARRAY_SIZE(fbd->ip_dst); idx--;) in fbnic_clear_nfc_ip_addr()
1023 __fbnic_ip_unsync(&fbd->ip_dst[idx], tcam_idx); in fbnic_clear_nfc_ip_addr()
1024 for (idx = ARRAY_SIZE(fbd->ipo_src); idx--;) in fbnic_clear_nfc_ip_addr()
1025 __fbnic_ip_unsync(&fbd->ipo_src[idx], tcam_idx); in fbnic_clear_nfc_ip_addr()
1026 for (idx = ARRAY_SIZE(fbd->ipo_dst); idx--;) in fbnic_clear_nfc_ip_addr()
1027 __fbnic_ip_unsync(&fbd->ipo_dst[idx], tcam_idx); in fbnic_clear_nfc_ip_addr()
1030 if (netif_running(fbn->netdev)) in fbnic_clear_nfc_ip_addr()
1038 struct fbnic_dev *fbd = fbn->fbd; in fbnic_set_cls_rule_del()
1042 fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; in fbnic_set_cls_rule_del()
1044 if (fsp->location >= FBNIC_RPC_ACT_TBL_NFC_ENTRIES) in fbnic_set_cls_rule_del()
1045 return -EINVAL; in fbnic_set_cls_rule_del()
1047 idx = fsp->location + FBNIC_RPC_ACT_TBL_NFC_OFFSET; in fbnic_set_cls_rule_del()
1048 act_tcam = &fbd->act_tcam[idx]; in fbnic_set_cls_rule_del()
1050 if (act_tcam->state != FBNIC_TCAM_S_VALID) in fbnic_set_cls_rule_del()
1051 return -EINVAL; in fbnic_set_cls_rule_del()
1053 act_tcam->state = FBNIC_TCAM_S_DELETE; in fbnic_set_cls_rule_del()
1055 if ((act_tcam->value.tcam[1] & FBNIC_RPC_TCAM_ACT1_L2_MACDA_VALID) && in fbnic_set_cls_rule_del()
1056 (~act_tcam->mask.tcam[1] & FBNIC_RPC_TCAM_ACT1_L2_MACDA_IDX)) in fbnic_set_cls_rule_del()
1059 if ((act_tcam->value.tcam[0] & in fbnic_set_cls_rule_del()
1064 (~act_tcam->mask.tcam[0] & in fbnic_set_cls_rule_del()
1071 if (netif_running(fbn->netdev)) in fbnic_set_cls_rule_del()
1080 int ret = -EOPNOTSUPP; in fbnic_set_rxnfc()
1082 switch (cmd->cmd) { in fbnic_set_rxnfc()
1113 rxfh->hfunc = ETH_RSS_HASH_TOP; in fbnic_get_rxfh()
1115 if (rxfh->key) { in fbnic_get_rxfh()
1117 u32 rss_key = fbn->rss_key[i / 4] << ((i % 4) * 8); in fbnic_get_rxfh()
1119 rxfh->key[i] = rss_key >> 24; in fbnic_get_rxfh()
1123 if (rxfh->indir) { in fbnic_get_rxfh()
1125 rxfh->indir[i] = fbn->indir_tbl[0][i]; in fbnic_get_rxfh()
1137 if (fbn->indir_tbl[idx][i] == indir[i]) in fbnic_set_indir()
1140 fbn->indir_tbl[idx][i] = indir[i]; in fbnic_set_indir()
1154 if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && in fbnic_set_rxfh()
1155 rxfh->hfunc != ETH_RSS_HASH_TOP) in fbnic_set_rxfh()
1156 return -EINVAL; in fbnic_set_rxfh()
1158 if (rxfh->key) { in fbnic_set_rxfh()
1161 for (i = FBNIC_RPC_RSS_KEY_BYTE_LEN; i--;) { in fbnic_set_rxfh()
1163 rss_key |= (u32)(rxfh->key[i]) << 24; in fbnic_set_rxfh()
1168 if (fbn->rss_key[i / 4] == rss_key) in fbnic_set_rxfh()
1171 fbn->rss_key[i / 4] = rss_key; in fbnic_set_rxfh()
1176 if (rxfh->indir) in fbnic_set_rxfh()
1177 changes += fbnic_set_indir(fbn, 0, rxfh->indir); in fbnic_set_rxfh()
1180 fbnic_rss_reinit_hw(fbn->fbd, fbn); in fbnic_set_rxfh()
1192 const u32 *indir = rxfh->indir; in fbnic_modify_rxfh_context()
1198 changes = fbnic_set_indir(fbn, rxfh->rss_context, indir); in fbnic_modify_rxfh_context()
1200 fbnic_rss_reinit_hw(fbn->fbd, fbn); in fbnic_modify_rxfh_context()
1213 if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) { in fbnic_create_rxfh_context()
1215 return -EOPNOTSUPP; in fbnic_create_rxfh_context()
1217 ctx->hfunc = ETH_RSS_HASH_TOP; in fbnic_create_rxfh_context()
1219 if (!rxfh->indir) { in fbnic_create_rxfh_context()
1221 unsigned int num_rx = fbn->num_rx_queues; in fbnic_create_rxfh_context()
1244 struct fbnic_dev *fbd = fbn->fbd; in fbnic_get_channels()
1246 ch->max_rx = fbd->max_num_queues; in fbnic_get_channels()
1247 ch->max_tx = fbd->max_num_queues; in fbnic_get_channels()
1248 ch->max_combined = min(ch->max_rx, ch->max_tx); in fbnic_get_channels()
1249 ch->max_other = FBNIC_NON_NAPI_VECTORS; in fbnic_get_channels()
1251 if (fbn->num_rx_queues > fbn->num_napi || in fbnic_get_channels()
1252 fbn->num_tx_queues > fbn->num_napi) in fbnic_get_channels()
1253 ch->combined_count = min(fbn->num_rx_queues, in fbnic_get_channels()
1254 fbn->num_tx_queues); in fbnic_get_channels()
1256 ch->combined_count = in fbnic_get_channels()
1257 fbn->num_rx_queues + fbn->num_tx_queues - fbn->num_napi; in fbnic_get_channels()
1258 ch->rx_count = fbn->num_rx_queues - ch->combined_count; in fbnic_get_channels()
1259 ch->tx_count = fbn->num_tx_queues - ch->combined_count; in fbnic_get_channels()
1260 ch->other_count = FBNIC_NON_NAPI_VECTORS; in fbnic_get_channels()
1266 fbn->num_rx_queues = ch->rx_count + ch->combined_count; in fbnic_set_queues()
1267 fbn->num_tx_queues = ch->tx_count + ch->combined_count; in fbnic_set_queues()
1268 fbn->num_napi = min(ch->rx_count + ch->tx_count + ch->combined_count, in fbnic_set_queues()
1277 struct fbnic_dev *fbd = fbn->fbd; in fbnic_set_channels()
1281 max_napis = fbd->num_irqs - FBNIC_NON_NAPI_VECTORS; in fbnic_set_channels()
1282 standalone = ch->rx_count + ch->tx_count; in fbnic_set_channels()
1285 * - each queue has it's own NAPI (num_napi >= rx + tx + combined) in fbnic_set_channels()
1286 * - combining queues (combined not 0, rx or tx must be 0) in fbnic_set_channels()
1288 if ((ch->rx_count && ch->tx_count && ch->combined_count) || in fbnic_set_channels()
1289 (standalone && standalone + ch->combined_count > max_napis) || in fbnic_set_channels()
1290 ch->rx_count + ch->combined_count > fbd->max_num_queues || in fbnic_set_channels()
1291 ch->tx_count + ch->combined_count > fbd->max_num_queues || in fbnic_set_channels()
1292 ch->other_count != FBNIC_NON_NAPI_VECTORS) in fbnic_set_channels()
1293 return -EINVAL; in fbnic_set_channels()
1303 return -ENOMEM; in fbnic_set_channels()
1316 err = fbnic_wait_all_queues_idle(fbn->fbd, true); in fbnic_set_channels()
1357 tsinfo->phc_index = ptp_clock_index(fbn->fbd->ptp); in fbnic_get_ts_info()
1359 tsinfo->so_timestamping = in fbnic_get_ts_info()
1365 tsinfo->tx_types = in fbnic_get_ts_info()
1369 tsinfo->rx_filters = in fbnic_get_ts_info()
1389 ts_stats->pkts = fbn->tx_stats.twq.ts_packets; in fbnic_get_ts_stats()
1390 ts_stats->lost = fbn->tx_stats.twq.ts_lost; in fbnic_get_ts_stats()
1391 for (i = 0; i < fbn->num_tx_queues; i++) { in fbnic_get_ts_stats()
1392 ring = fbn->tx[i]; in fbnic_get_ts_stats()
1394 start = u64_stats_fetch_begin(&ring->stats.syncp); in fbnic_get_ts_stats()
1395 ts_packets = ring->stats.twq.ts_packets; in fbnic_get_ts_stats()
1396 ts_lost = ring->stats.twq.ts_lost; in fbnic_get_ts_stats()
1397 } while (u64_stats_fetch_retry(&ring->stats.syncp, start)); in fbnic_get_ts_stats()
1398 ts_stats->pkts += ts_packets; in fbnic_get_ts_stats()
1399 ts_stats->lost += ts_lost; in fbnic_get_ts_stats()
1405 if (counter->reported) in fbnic_set_counter()
1406 *stat = counter->value; in fbnic_set_counter()
1415 struct fbnic_dev *fbd = fbn->fbd; in fbnic_get_eth_mac_stats()
1418 mac_stats = &fbd->hw_stats.mac; in fbnic_get_eth_mac_stats()
1419 mac = fbd->mac; in fbnic_get_eth_mac_stats()
1421 mac->get_eth_mac_stats(fbd, false, &mac_stats->eth_mac); in fbnic_get_eth_mac_stats()
1423 fbnic_set_counter(ð_mac_stats->FramesTransmittedOK, in fbnic_get_eth_mac_stats()
1424 &mac_stats->eth_mac.FramesTransmittedOK); in fbnic_get_eth_mac_stats()
1425 fbnic_set_counter(ð_mac_stats->FramesReceivedOK, in fbnic_get_eth_mac_stats()
1426 &mac_stats->eth_mac.FramesReceivedOK); in fbnic_get_eth_mac_stats()
1427 fbnic_set_counter(ð_mac_stats->FrameCheckSequenceErrors, in fbnic_get_eth_mac_stats()
1428 &mac_stats->eth_mac.FrameCheckSequenceErrors); in fbnic_get_eth_mac_stats()
1429 fbnic_set_counter(ð_mac_stats->AlignmentErrors, in fbnic_get_eth_mac_stats()
1430 &mac_stats->eth_mac.AlignmentErrors); in fbnic_get_eth_mac_stats()
1431 fbnic_set_counter(ð_mac_stats->OctetsTransmittedOK, in fbnic_get_eth_mac_stats()
1432 &mac_stats->eth_mac.OctetsTransmittedOK); in fbnic_get_eth_mac_stats()
1433 fbnic_set_counter(ð_mac_stats->FramesLostDueToIntMACXmitError, in fbnic_get_eth_mac_stats()
1434 &mac_stats->eth_mac.FramesLostDueToIntMACXmitError); in fbnic_get_eth_mac_stats()
1435 fbnic_set_counter(ð_mac_stats->OctetsReceivedOK, in fbnic_get_eth_mac_stats()
1436 &mac_stats->eth_mac.OctetsReceivedOK); in fbnic_get_eth_mac_stats()
1437 fbnic_set_counter(ð_mac_stats->FramesLostDueToIntMACRcvError, in fbnic_get_eth_mac_stats()
1438 &mac_stats->eth_mac.FramesLostDueToIntMACRcvError); in fbnic_get_eth_mac_stats()
1439 fbnic_set_counter(ð_mac_stats->MulticastFramesXmittedOK, in fbnic_get_eth_mac_stats()
1440 &mac_stats->eth_mac.MulticastFramesXmittedOK); in fbnic_get_eth_mac_stats()
1441 fbnic_set_counter(ð_mac_stats->BroadcastFramesXmittedOK, in fbnic_get_eth_mac_stats()
1442 &mac_stats->eth_mac.BroadcastFramesXmittedOK); in fbnic_get_eth_mac_stats()
1443 fbnic_set_counter(ð_mac_stats->MulticastFramesReceivedOK, in fbnic_get_eth_mac_stats()
1444 &mac_stats->eth_mac.MulticastFramesReceivedOK); in fbnic_get_eth_mac_stats()
1445 fbnic_set_counter(ð_mac_stats->BroadcastFramesReceivedOK, in fbnic_get_eth_mac_stats()
1446 &mac_stats->eth_mac.BroadcastFramesReceivedOK); in fbnic_get_eth_mac_stats()
1447 fbnic_set_counter(ð_mac_stats->FrameTooLongErrors, in fbnic_get_eth_mac_stats()
1448 &mac_stats->eth_mac.FrameTooLongErrors); in fbnic_get_eth_mac_stats()
1484 dev->ethtool_ops = &fbnic_ethtool_ops; in fbnic_set_ethtool_ops()