@@ -406,11 +406,11 @@ static int sparx5_handle_port_mdb_add(struct net_device *dev,
406406
407407 res = sparx5_mact_find (spx5 , v -> addr , vid , & mact_entry );
408408
409- if (res ) {
409+ if (res == 0 ) {
410410 pgid_idx = LRN_MAC_ACCESS_CFG_2_MAC_ENTRY_ADDR_GET (mact_entry );
411411
412- /* MC_IDX has an offset of 65 in the PGID table. */
413- pgid_idx += PGID_MCAST_START ;
412+ /* MC_IDX starts after the port masks in the PGID table */
413+ pgid_idx += SPX5_PORTS ;
414414 sparx5_pgid_update_mask (port , pgid_idx , true);
415415 } else {
416416 err = sparx5_pgid_alloc_mcast (spx5 , & pgid_idx );
@@ -468,17 +468,15 @@ static int sparx5_handle_port_mdb_del(struct net_device *dev,
468468
469469 res = sparx5_mact_find (spx5 , v -> addr , vid , & mact_entry );
470470
471- if (res ) {
471+ if (res == 0 ) {
472472 pgid_idx = LRN_MAC_ACCESS_CFG_2_MAC_ENTRY_ADDR_GET (mact_entry );
473473
474- /* MC_IDX has an offset of 65 in the PGID table. */
475- pgid_idx += PGID_MCAST_START ;
474+ /* MC_IDX starts after the port masks in the PGID table */
475+ pgid_idx += SPX5_PORTS ;
476476 sparx5_pgid_update_mask (port , pgid_idx , false);
477477
478- pgid_entry [0 ] = spx5_rd (spx5 , ANA_AC_PGID_CFG (pgid_idx ));
479- pgid_entry [1 ] = spx5_rd (spx5 , ANA_AC_PGID_CFG1 (pgid_idx ));
480- pgid_entry [2 ] = spx5_rd (spx5 , ANA_AC_PGID_CFG2 (pgid_idx ));
481- if (pgid_entry [0 ] == 0 && pgid_entry [1 ] == 0 && pgid_entry [2 ] == 0 ) {
478+ sparx5_pgid_read_mask (spx5 , pgid_idx , pgid_entry );
479+ if (bitmap_empty ((unsigned long * )pgid_entry , SPX5_PORTS )) {
482480 /* No ports are in MC group. Remove entry */
483481 err = sparx5_mdb_del_entry (dev , spx5 , v -> addr , vid , pgid_idx );
484482 if (err )
0 commit comments