@@ -491,28 +491,24 @@ static int bcm_sf2_cfp_ipv4_rule_get(struct bcm_sf2_priv *priv, int port,
491
491
}
492
492
493
493
static int bcm_sf2_cfp_rule_get (struct bcm_sf2_priv * priv , int port ,
494
- struct ethtool_rxnfc * nfc , bool search )
494
+ struct ethtool_rxnfc * nfc )
495
495
{
496
496
struct ethtool_tcpip4_spec * v4_spec = NULL , * v4_m_spec ;
497
497
unsigned int queue_num ;
498
498
u32 reg ;
499
499
int ret ;
500
500
501
- if (!search ) {
502
- bcm_sf2_cfp_rule_addr_set (priv , nfc -> fs .location );
501
+ bcm_sf2_cfp_rule_addr_set (priv , nfc -> fs .location );
503
502
504
- ret = bcm_sf2_cfp_op (priv , OP_SEL_READ | ACT_POL_RAM );
505
- if (ret )
506
- return ret ;
503
+ ret = bcm_sf2_cfp_op (priv , OP_SEL_READ | ACT_POL_RAM );
504
+ if (ret )
505
+ return ret ;
507
506
508
- reg = core_readl (priv , CORE_ACT_POL_DATA0 );
507
+ reg = core_readl (priv , CORE_ACT_POL_DATA0 );
509
508
510
- ret = bcm_sf2_cfp_op (priv , OP_SEL_READ | TCAM_SEL );
511
- if (ret )
512
- return ret ;
513
- } else {
514
- reg = core_readl (priv , CORE_ACT_POL_DATA0 );
515
- }
509
+ ret = bcm_sf2_cfp_op (priv , OP_SEL_READ | TCAM_SEL );
510
+ if (ret )
511
+ return ret ;
516
512
517
513
/* Extract the destination port */
518
514
nfc -> fs .ring_cookie = fls ((reg >> DST_MAP_IB_SHIFT ) &
@@ -541,9 +537,6 @@ static int bcm_sf2_cfp_rule_get(struct bcm_sf2_priv *priv, int port,
541
537
v4_m_spec = & nfc -> fs .m_u .udp_ip4_spec ;
542
538
break ;
543
539
default :
544
- /* Clear to exit the search process */
545
- if (search )
546
- core_readl (priv , CORE_CFP_DATA_PORT (7 ));
547
540
return - EINVAL ;
548
541
}
549
542
@@ -577,44 +570,11 @@ static int bcm_sf2_cfp_rule_get_all(struct bcm_sf2_priv *priv,
577
570
u32 * rule_locs )
578
571
{
579
572
unsigned int index = 1 , rules_cnt = 0 ;
580
- int ret ;
581
- u32 reg ;
582
573
583
- /* Do not poll on OP_STR_DONE to be self-clearing for search
584
- * operations, we cannot use bcm_sf2_cfp_op here because it completes
585
- * on clearing OP_STR_DONE which won't clear until the entire search
586
- * operation is over.
587
- */
588
- reg = core_readl (priv , CORE_CFP_ACC );
589
- reg &= ~(XCESS_ADDR_MASK << XCESS_ADDR_SHIFT );
590
- reg |= index << XCESS_ADDR_SHIFT ;
591
- reg &= ~(OP_SEL_MASK | RAM_SEL_MASK );
592
- reg |= OP_SEL_SEARCH | TCAM_SEL | OP_STR_DONE ;
593
- core_writel (priv , reg , CORE_CFP_ACC );
594
-
595
- do {
596
- /* Wait for results to be ready */
597
- reg = core_readl (priv , CORE_CFP_ACC );
598
-
599
- /* Extract the address we are searching */
600
- index = reg >> XCESS_ADDR_SHIFT ;
601
- index &= XCESS_ADDR_MASK ;
602
-
603
- /* We have a valid search result, so flag it accordingly */
604
- if (reg & SEARCH_STS ) {
605
- ret = bcm_sf2_cfp_rule_get (priv , port , nfc , true);
606
- if (ret )
607
- continue ;
608
-
609
- rule_locs [rules_cnt ] = index ;
610
- rules_cnt ++ ;
611
- }
612
-
613
- /* Search is over break out */
614
- if (!(reg & OP_STR_DONE ))
615
- break ;
616
-
617
- } while (index < priv -> num_cfp_rules );
574
+ for_each_set_bit_from (index , priv -> cfp .used , priv -> num_cfp_rules ) {
575
+ rule_locs [rules_cnt ] = index ;
576
+ rules_cnt ++ ;
577
+ }
618
578
619
579
/* Put the TCAM size here */
620
580
nfc -> data = bcm_sf2_cfp_rule_size (priv );
@@ -640,7 +600,7 @@ int bcm_sf2_get_rxnfc(struct dsa_switch *ds, int port,
640
600
nfc -> data |= RX_CLS_LOC_SPECIAL ;
641
601
break ;
642
602
case ETHTOOL_GRXCLSRULE :
643
- ret = bcm_sf2_cfp_rule_get (priv , port , nfc , false );
603
+ ret = bcm_sf2_cfp_rule_get (priv , port , nfc );
644
604
break ;
645
605
case ETHTOOL_GRXCLSRLALL :
646
606
ret = bcm_sf2_cfp_rule_get_all (priv , port , nfc , rule_locs );
0 commit comments