Skip to content

Commit afec498

Browse files
committed
Merge branch 'net-sparx5-refactor-based-on-feedback-on'
Casper Andersson says: ==================== net: sparx5: Refactor based on feedback on This is a follow up to a previous patch that was merged before manufacturer could give feedback. This addresses the feedback. See link below for previous patch series. https://lore.kernel.org/netdev/20220322081823.wqbx7vud4q7qtjuq@wse-c0155/T/#t ==================== Link: https://lore.kernel.org/r/20220324113853.576803-1-casper.casan@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents feb13dc + ad238fc commit afec498

File tree

5 files changed

+24
-47
lines changed

5 files changed

+24
-47
lines changed

drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,7 @@ bool sparx5_mact_find(struct sparx5 *sparx5,
212212

213213
mutex_unlock(&sparx5->lock);
214214

215-
return ret == 0;
216-
}
217-
218-
static int sparx5_mact_lookup(struct sparx5 *sparx5,
219-
const unsigned char mac[ETH_ALEN],
220-
u16 vid)
221-
{
222-
u32 pcfg2;
223-
224-
if (sparx5_mact_find(sparx5, mac, vid, &pcfg2))
225-
return 1;
226-
227-
return 0;
215+
return ret;
228216
}
229217

230218
int sparx5_mact_forget(struct sparx5 *sparx5,
@@ -305,9 +293,10 @@ int sparx5_add_mact_entry(struct sparx5 *sparx5,
305293
{
306294
struct sparx5_mact_entry *mact_entry;
307295
int ret;
296+
u32 cfg2;
308297

309-
ret = sparx5_mact_lookup(sparx5, addr, vid);
310-
if (ret)
298+
ret = sparx5_mact_find(sparx5, addr, vid, &cfg2);
299+
if (!ret)
311300
return 0;
312301

313302
/* In case the entry already exists, don't add it again to SW,

drivers/net/ethernet/microchip/sparx5/sparx5_main.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,10 @@ enum sparx5_vlan_port_type {
6565
#define PGID_IPV6_MC_CTRL (PGID_BASE + 5)
6666
#define PGID_BCAST (PGID_BASE + 6)
6767
#define PGID_CPU (PGID_BASE + 7)
68+
#define PGID_MCAST_START (PGID_BASE + 8)
6869

6970
#define PGID_TABLE_SIZE 3290
7071

71-
#define PGID_MCAST_START 65
72-
#define PGID_GLAG_START 833
73-
#define PGID_GLAG_END 1088
74-
7572
#define IFH_LEN 9 /* 36 bytes */
7673
#define NULL_VID 0
7774
#define SPX5_MACT_PULL_DELAY (2 * HZ)
@@ -328,6 +325,7 @@ void sparx5_mact_init(struct sparx5 *sparx5);
328325

329326
/* sparx5_vlan.c */
330327
void sparx5_pgid_update_mask(struct sparx5_port *port, int pgid, bool enable);
328+
void sparx5_pgid_read_mask(struct sparx5 *sparx5, int pgid, u32 portmask[3]);
331329
void sparx5_update_fwd(struct sparx5 *sparx5);
332330
void sparx5_vlan_init(struct sparx5 *sparx5);
333331
void sparx5_vlan_port_setup(struct sparx5 *sparx5, int portno);
@@ -374,7 +372,6 @@ enum sparx5_pgid_type {
374372
SPX5_PGID_FREE,
375373
SPX5_PGID_RESERVED,
376374
SPX5_PGID_MULTICAST,
377-
SPX5_PGID_GLAG
378375
};
379376

380377
void sparx5_pgid_init(struct sparx5 *spx5);

drivers/net/ethernet/microchip/sparx5/sparx5_pgid.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,14 @@ void sparx5_pgid_init(struct sparx5 *spx5)
1515
spx5->pgid_map[i] = SPX5_PGID_RESERVED;
1616
}
1717

18-
int sparx5_pgid_alloc_glag(struct sparx5 *spx5, u16 *idx)
19-
{
20-
int i;
21-
22-
for (i = PGID_GLAG_START; i <= PGID_GLAG_END; i++)
23-
if (spx5->pgid_map[i] == SPX5_PGID_FREE) {
24-
spx5->pgid_map[i] = SPX5_PGID_GLAG;
25-
*idx = i;
26-
return 0;
27-
}
28-
29-
return -EBUSY;
30-
}
31-
3218
int sparx5_pgid_alloc_mcast(struct sparx5 *spx5, u16 *idx)
3319
{
3420
int i;
3521

22+
/* The multicast area starts at index 65, but the first 7
23+
* are reserved for flood masks and CPU. Start alloc after that.
24+
*/
3625
for (i = PGID_MCAST_START; i < PGID_TABLE_SIZE; i++) {
37-
if (i == PGID_GLAG_START)
38-
i = PGID_GLAG_END + 1;
39-
4026
if (spx5->pgid_map[i] == SPX5_PGID_FREE) {
4127
spx5->pgid_map[i] = SPX5_PGID_MULTICAST;
4228
*idx = i;

drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ void sparx5_pgid_update_mask(struct sparx5_port *port, int pgid, bool enable)
138138
}
139139
}
140140

141+
void sparx5_pgid_read_mask(struct sparx5 *spx5, int pgid, u32 portmask[3])
142+
{
143+
portmask[0] = spx5_rd(spx5, ANA_AC_PGID_CFG(pgid));
144+
portmask[1] = spx5_rd(spx5, ANA_AC_PGID_CFG1(pgid));
145+
portmask[2] = spx5_rd(spx5, ANA_AC_PGID_CFG2(pgid));
146+
}
147+
141148
void sparx5_update_fwd(struct sparx5 *sparx5)
142149
{
143150
DECLARE_BITMAP(workmask, SPX5_PORTS);

0 commit comments

Comments
 (0)