Lines Matching +full:tcam +full:- +full:based

1 // SPDX-License-Identifier: GPL-2.0
13 unsigned int num_rx = fbn->num_rx_queues; in fbnic_reset_indir_tbl()
17 fbn->indir_tbl[0][i] = ethtool_rxfh_indir_default(i, num_rx); in fbnic_reset_indir_tbl()
18 fbn->indir_tbl[1][i] = ethtool_rxfh_indir_default(i, num_rx); in fbnic_reset_indir_tbl()
40 fbn->rss_flow_hash[FBNIC_TCP4_HASH_OPT] = RX_HASH_OPT_L4; in fbnic_rss_init_en_mask()
41 fbn->rss_flow_hash[FBNIC_TCP6_HASH_OPT] = RX_HASH_OPT_L4; in fbnic_rss_init_en_mask()
43 fbn->rss_flow_hash[FBNIC_UDP4_HASH_OPT] = RX_HASH_OPT_L3; in fbnic_rss_init_en_mask()
44 fbn->rss_flow_hash[FBNIC_UDP6_HASH_OPT] = RX_HASH_OPT_L3; in fbnic_rss_init_en_mask()
45 fbn->rss_flow_hash[FBNIC_IPV4_HASH_OPT] = RX_HASH_OPT_L3; in fbnic_rss_init_en_mask()
46 fbn->rss_flow_hash[FBNIC_IPV6_HASH_OPT] = RX_HASH_OPT_L3; in fbnic_rss_init_en_mask()
48 fbn->rss_flow_hash[FBNIC_ETHER_HASH_OPT] = RX_HASH_OPT_L2; in fbnic_rss_init_en_mask()
64 u32 flow_hash = fbn->rss_flow_hash[flow_type]; in fbnic_flow_hash_2_rss_en_mask()
81 wr32(fbd, FBNIC_RPC_RSS_TBL(0, i), fbn->indir_tbl[0][i]); in fbnic_rss_reinit_hw()
82 wr32(fbd, FBNIC_RPC_RSS_TBL(1, i), fbn->indir_tbl[1][i]); in fbnic_rss_reinit_hw()
86 wr32(fbd, FBNIC_RPC_RSS_KEY(i), fbn->rss_key[i]); in fbnic_rss_reinit_hw()
114 mac_addr = &fbd->mac_addr[fbd->mac_addr_boundary - 1]; in fbnic_bmc_rpc_all_multi_config()
115 if (fbnic_bmc_present(fbd) && fbd->fw_cap.all_multi) { in fbnic_bmc_rpc_all_multi_config()
116 if (mac_addr->state != FBNIC_TCAM_S_VALID) { in fbnic_bmc_rpc_all_multi_config()
117 eth_zero_addr(mac_addr->value.addr8); in fbnic_bmc_rpc_all_multi_config()
118 eth_broadcast_addr(mac_addr->mask.addr8); in fbnic_bmc_rpc_all_multi_config()
119 mac_addr->value.addr8[0] ^= 1; in fbnic_bmc_rpc_all_multi_config()
120 mac_addr->mask.addr8[0] ^= 1; in fbnic_bmc_rpc_all_multi_config()
121 set_bit(FBNIC_MAC_ADDR_T_BMC, mac_addr->act_tcam); in fbnic_bmc_rpc_all_multi_config()
122 mac_addr->state = FBNIC_TCAM_S_ADD; in fbnic_bmc_rpc_all_multi_config()
126 mac_addr->act_tcam); in fbnic_bmc_rpc_all_multi_config()
129 mac_addr->act_tcam); in fbnic_bmc_rpc_all_multi_config()
130 } else if (!test_bit(FBNIC_MAC_ADDR_T_BMC, mac_addr->act_tcam) && in fbnic_bmc_rpc_all_multi_config()
131 !is_zero_ether_addr(mac_addr->mask.addr8) && in fbnic_bmc_rpc_all_multi_config()
132 mac_addr->state == FBNIC_TCAM_S_VALID) { in fbnic_bmc_rpc_all_multi_config()
133 clear_bit(FBNIC_MAC_ADDR_T_ALLMULTI, mac_addr->act_tcam); in fbnic_bmc_rpc_all_multi_config()
134 clear_bit(FBNIC_MAC_ADDR_T_BMC, mac_addr->act_tcam); in fbnic_bmc_rpc_all_multi_config()
135 mac_addr->state = FBNIC_TCAM_S_DELETE; in fbnic_bmc_rpc_all_multi_config()
139 * BMC may have an all-multi rule already in place. As such in fbnic_bmc_rpc_all_multi_config()
144 act_tcam = &fbd->act_tcam[FBNIC_RPC_ACT_TBL_BMC_ALL_MULTI_OFFSET]; in fbnic_bmc_rpc_all_multi_config()
149 if (!fbnic_bmc_present(fbd) || !fbd->fw_cap.all_multi || enable_host) { in fbnic_bmc_rpc_all_multi_config()
150 if (act_tcam->state == FBNIC_TCAM_S_VALID) in fbnic_bmc_rpc_all_multi_config()
151 act_tcam->state = FBNIC_TCAM_S_DELETE; in fbnic_bmc_rpc_all_multi_config()
155 /* Rewrite TCAM rule 23 to handle BMC all-multi traffic */ in fbnic_bmc_rpc_all_multi_config()
156 act_tcam->dest = FIELD_PREP(FBNIC_RPC_ACT_TBL0_DEST_MASK, in fbnic_bmc_rpc_all_multi_config()
158 act_tcam->mask.tcam[0] = 0xffff; in fbnic_bmc_rpc_all_multi_config()
160 /* MACDA 0 - 3 is reserved for the BMC MAC address */ in fbnic_bmc_rpc_all_multi_config()
161 act_tcam->value.tcam[1] = in fbnic_bmc_rpc_all_multi_config()
163 fbd->mac_addr_boundary - 1) | in fbnic_bmc_rpc_all_multi_config()
165 act_tcam->mask.tcam[1] = 0xffff & in fbnic_bmc_rpc_all_multi_config()
170 act_tcam->mask.tcam[j] = 0xffff; in fbnic_bmc_rpc_all_multi_config()
172 act_tcam->state = FBNIC_TCAM_S_UPDATE; in fbnic_bmc_rpc_all_multi_config()
188 u8 *bmc_mac = fbd->fw_cap.bmc_mac_addr[j]; in fbnic_bmc_rpc_init()
197 mac_addr = &fbd->mac_addr[i++]; in fbnic_bmc_rpc_init()
200 netdev_err(fbd->netdev, in fbnic_bmc_rpc_init()
205 ether_addr_copy(mac_addr->value.addr8, bmc_mac); in fbnic_bmc_rpc_init()
206 eth_zero_addr(mac_addr->mask.addr8); in fbnic_bmc_rpc_init()
208 set_bit(FBNIC_MAC_ADDR_T_BMC, mac_addr->act_tcam); in fbnic_bmc_rpc_init()
209 mac_addr->state = FBNIC_TCAM_S_ADD; in fbnic_bmc_rpc_init()
213 mac_addr = &fbd->mac_addr[FBNIC_RPC_TCAM_MACDA_BROADCAST_IDX]; in fbnic_bmc_rpc_init()
214 eth_broadcast_addr(mac_addr->value.addr8); in fbnic_bmc_rpc_init()
215 set_bit(FBNIC_MAC_ADDR_T_BMC, mac_addr->act_tcam); in fbnic_bmc_rpc_init()
216 mac_addr->state = FBNIC_TCAM_S_ADD; in fbnic_bmc_rpc_init()
218 /* Rewrite TCAM rule 0 if it isn't present to relocate BMC rules */ in fbnic_bmc_rpc_init()
219 act_tcam = &fbd->act_tcam[FBNIC_RPC_ACT_TBL_BMC_OFFSET]; in fbnic_bmc_rpc_init()
220 act_tcam->dest = FIELD_PREP(FBNIC_RPC_ACT_TBL0_DEST_MASK, in fbnic_bmc_rpc_init()
222 act_tcam->mask.tcam[0] = 0xffff; in fbnic_bmc_rpc_init()
224 /* MACDA 0 - 3 is reserved for the BMC MAC address in fbnic_bmc_rpc_init()
228 act_tcam->value.tcam[1] = FBNIC_RPC_TCAM_ACT1_L2_MACDA_VALID; in fbnic_bmc_rpc_init()
229 act_tcam->mask.tcam[1] = 0xffff & in fbnic_bmc_rpc_init()
234 act_tcam->mask.tcam[j] = 0xffff; in fbnic_bmc_rpc_init()
236 act_tcam->state = FBNIC_TCAM_S_UPDATE; in fbnic_bmc_rpc_init()
267 /* Program RSS hash enable mask for host in action TCAM/table. */ in fbnic_rss_reinit()
271 struct fbnic_act_tcam *act_tcam = &fbd->act_tcam[idx]; in fbnic_rss_reinit()
277 flow_hash = fbn->rss_flow_hash[flow_type]; in fbnic_rss_reinit()
279 /* Set DEST_HOST based on absence of RXH_DISCARD */ in fbnic_rss_reinit()
297 act_tcam->dest = dest; in fbnic_rss_reinit()
298 act_tcam->rss_en_mask = rss_en_mask; in fbnic_rss_reinit()
299 act_tcam->state = FBNIC_TCAM_S_UPDATE; in fbnic_rss_reinit()
301 act_tcam->mask.tcam[0] = 0xffff; in fbnic_rss_reinit()
303 /* We reserve the upper 8 MACDA TCAM entries for host in fbnic_rss_reinit()
310 fbd->mac_addr_boundary); in fbnic_rss_reinit()
316 act_tcam->value.tcam[1] = value; in fbnic_rss_reinit()
317 act_tcam->mask.tcam[1] = ~value; in fbnic_rss_reinit()
320 act_tcam->mask.tcam[j] = 0xffff; in fbnic_rss_reinit()
322 act_tcam->state = FBNIC_TCAM_S_UPDATE; in fbnic_rss_reinit()
336 for (i = fbd->mac_addr_boundary - 1; in __fbnic_uc_sync()
338 struct fbnic_mac_addr *mac_addr = &fbd->mac_addr[i]; in __fbnic_uc_sync()
340 if (mac_addr->state == FBNIC_TCAM_S_DISABLED) { in __fbnic_uc_sync()
342 } else if (ether_addr_equal(mac_addr->value.addr8, addr)) { in __fbnic_uc_sync()
348 if (avail_addr && avail_addr->state == FBNIC_TCAM_S_DISABLED) { in __fbnic_uc_sync()
349 ether_addr_copy(avail_addr->value.addr8, addr); in __fbnic_uc_sync()
350 eth_zero_addr(avail_addr->mask.addr8); in __fbnic_uc_sync()
351 avail_addr->state = FBNIC_TCAM_S_ADD; in __fbnic_uc_sync()
367 for (i = fbd->mac_addr_boundary; in __fbnic_mc_sync()
368 --i > FBNIC_RPC_TCAM_MACDA_BROADCAST_IDX;) { in __fbnic_mc_sync()
369 struct fbnic_mac_addr *mac_addr = &fbd->mac_addr[i]; in __fbnic_mc_sync()
371 if (mac_addr->state == FBNIC_TCAM_S_DISABLED) { in __fbnic_mc_sync()
373 } else if (ether_addr_equal(mac_addr->value.addr8, addr)) { in __fbnic_mc_sync()
382 while (--i) { in __fbnic_mc_sync()
383 struct fbnic_mac_addr *mac_addr = &fbd->mac_addr[i]; in __fbnic_mc_sync()
385 if (!is_zero_ether_addr(mac_addr->mask.addr8)) in __fbnic_mc_sync()
389 if (!ether_addr_equal(mac_addr->value.addr8, addr)) in __fbnic_mc_sync()
395 mac_addr->state = FBNIC_TCAM_S_DELETE; in __fbnic_mc_sync()
396 avail_addr->state = FBNIC_TCAM_S_ADD; in __fbnic_mc_sync()
402 if (avail_addr && avail_addr->state == FBNIC_TCAM_S_DISABLED) { in __fbnic_mc_sync()
403 ether_addr_copy(avail_addr->value.addr8, addr); in __fbnic_mc_sync()
404 eth_zero_addr(avail_addr->mask.addr8); in __fbnic_mc_sync()
405 avail_addr->state = FBNIC_TCAM_S_ADD; in __fbnic_mc_sync()
413 if (!test_and_clear_bit(tcam_idx, mac_addr->act_tcam)) in __fbnic_xc_unsync()
414 return -ENOENT; in __fbnic_xc_unsync()
416 if (bitmap_empty(mac_addr->act_tcam, FBNIC_RPC_TCAM_ACT_NUM_ENTRIES)) in __fbnic_xc_unsync()
417 mac_addr->state = FBNIC_TCAM_S_DELETE; in __fbnic_xc_unsync()
430 src < fbd->mac_addr_boundary;) { in fbnic_sift_macda()
431 struct fbnic_mac_addr *dest_addr = &fbd->mac_addr[dest]; in fbnic_sift_macda()
433 if (dest_addr->state != FBNIC_TCAM_S_DISABLED) in fbnic_sift_macda()
436 while (src < fbd->mac_addr_boundary) { in fbnic_sift_macda()
437 struct fbnic_mac_addr *src_addr = &fbd->mac_addr[src++]; in fbnic_sift_macda()
440 if (!test_bit(FBNIC_MAC_ADDR_T_BMC, src_addr->act_tcam)) in fbnic_sift_macda()
444 if (src_addr->state == FBNIC_TCAM_S_DISABLED || in fbnic_sift_macda()
445 src_addr->state == FBNIC_TCAM_S_DELETE) in fbnic_sift_macda()
449 if (bitmap_weight(src_addr->act_tcam, in fbnic_sift_macda()
454 if (!is_zero_ether_addr(src_addr->mask.addr8)) in fbnic_sift_macda()
458 src_addr->state = FBNIC_TCAM_S_DELETE; in fbnic_sift_macda()
459 dest_addr->state = FBNIC_TCAM_S_ADD; in fbnic_sift_macda()
477 for (idx = ARRAY_SIZE(fbd->mac_addr); idx--;) { in fbnic_clear_macda()
478 struct fbnic_mac_addr *mac_addr = &fbd->mac_addr[idx]; in fbnic_clear_macda()
480 if (mac_addr->state == FBNIC_TCAM_S_DISABLED) in fbnic_clear_macda()
483 if (test_bit(FBNIC_MAC_ADDR_T_BMC, mac_addr->act_tcam)) { in fbnic_clear_macda()
486 dev_warn_once(fbd->dev, in fbnic_clear_macda()
493 if (mac_addr->state == FBNIC_TCAM_S_DELETE) { in fbnic_clear_macda()
499 * this tcam the next time fbnic_write_macda is called. in fbnic_clear_macda()
501 mac_addr->state = FBNIC_TCAM_S_UPDATE; in fbnic_clear_macda()
511 mask = &mac_addr->mask.addr16[FBNIC_RPC_TCAM_MACDA_WORD_LEN - 1]; in fbnic_write_macda_entry()
512 value = &mac_addr->value.addr16[FBNIC_RPC_TCAM_MACDA_WORD_LEN - 1]; in fbnic_write_macda_entry()
516 FIELD_PREP(FBNIC_RPC_TCAM_MACDA_MASK, ntohs(*mask--)) | in fbnic_write_macda_entry()
517 FIELD_PREP(FBNIC_RPC_TCAM_MACDA_VALUE, ntohs(*value--))); in fbnic_write_macda_entry()
528 for (idx = ARRAY_SIZE(fbd->mac_addr); idx--;) { in fbnic_write_macda()
529 struct fbnic_mac_addr *mac_addr = &fbd->mac_addr[idx]; in fbnic_write_macda()
532 if (!(mac_addr->state & FBNIC_TCAM_S_UPDATE)) in fbnic_write_macda()
536 if (mac_addr->state == FBNIC_TCAM_S_DELETE) { in fbnic_write_macda()
546 mac_addr->state = FBNIC_TCAM_S_VALID; in fbnic_write_macda()
563 int i = FBNIC_RPC_TCAM_ACT_NUM_ENTRIES - 1; in fbnic_clear_rules()
580 act_tcam = &fbd->act_tcam[i]; in fbnic_clear_rules()
582 if (act_tcam->state == FBNIC_TCAM_S_VALID && in fbnic_clear_rules()
583 (act_tcam->dest & dest)) { in fbnic_clear_rules()
587 act_tcam->state = FBNIC_TCAM_S_UPDATE; in fbnic_clear_rules()
589 i--; in fbnic_clear_rules()
595 act_tcam = &fbd->act_tcam[i]; in fbnic_clear_rules()
597 if (act_tcam->state != FBNIC_TCAM_S_VALID) in fbnic_clear_rules()
601 act_tcam->state = FBNIC_TCAM_S_UPDATE; in fbnic_clear_rules()
602 } while (i--); in fbnic_clear_rules()
608 memset(&fbd->act_tcam[idx], 0, sizeof(struct fbnic_act_tcam)); in fbnic_delete_act_tcam()
613 struct fbnic_act_tcam *act_tcam = &fbd->act_tcam[idx]; in fbnic_update_act_tcam()
617 wr32(fbd, FBNIC_RPC_ACT_TBL0(idx), act_tcam->dest); in fbnic_update_act_tcam()
618 wr32(fbd, FBNIC_RPC_ACT_TBL1(idx), act_tcam->rss_en_mask); in fbnic_update_act_tcam()
620 /* Write new TCAM rule to hardware */ in fbnic_update_act_tcam()
624 act_tcam->mask.tcam[i]) | in fbnic_update_act_tcam()
626 act_tcam->value.tcam[i])); in fbnic_update_act_tcam()
631 act_tcam->state = FBNIC_TCAM_S_VALID; in fbnic_update_act_tcam()
640 struct fbnic_act_tcam *act_tcam = &fbd->act_tcam[i]; in fbnic_write_rules()
643 if (!(act_tcam->state & FBNIC_TCAM_S_UPDATE)) in fbnic_write_rules()
646 if (act_tcam->state == FBNIC_TCAM_S_DELETE) in fbnic_write_rules()