aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2017-05-01 14:05:16 -0400
committerDavid S. Miller <davem@davemloft.net>2017-05-01 15:03:10 -0400
commit3afb4bde6fe8f2d43b2153cc2672d07477729cca (patch)
treef757585c4a4d710d50cf232aa53f885114088b51
parentd2ca1ea18db6a90475b983e65e8435632fe3d57e (diff)
net: dsa: mv88e6xxx: move VTU VID accessors
Add helpers to access the VTU VID register in the global1_vtu.c file. At the same time, move mv88e6xxx_g1_vtu_vid_write at the beginning of _mv88e6xxx_vtu_loadpurge, which adds no functional changes but makes future patches simpler. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c57
-rw-r--r--drivers/net/dsa/mv88e6xxx/global1.h4
-rw-r--r--drivers/net/dsa/mv88e6xxx/global1_vtu.c29
3 files changed, 56 insertions, 34 deletions
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index ec621879439d..dce490e78347 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1337,12 +1337,6 @@ static int mv88e6xxx_stu_data_write(struct mv88e6xxx_chip *chip,
1337 return _mv88e6xxx_vtu_stu_data_write(chip, entry, 2); 1337 return _mv88e6xxx_vtu_stu_data_write(chip, entry, 2);
1338} 1338}
1339 1339
1340static int _mv88e6xxx_vtu_vid_write(struct mv88e6xxx_chip *chip, u16 vid)
1341{
1342 return mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID,
1343 vid & GLOBAL_VTU_VID_MASK);
1344}
1345
1346static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip, 1340static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1347 struct mv88e6xxx_vtu_entry *entry) 1341 struct mv88e6xxx_vtu_entry *entry)
1348{ 1342{
@@ -1358,13 +1352,10 @@ static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1358 if (err) 1352 if (err)
1359 return err; 1353 return err;
1360 1354
1361 err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_VID, &val); 1355 err = mv88e6xxx_g1_vtu_vid_read(chip, &next);
1362 if (err) 1356 if (err)
1363 return err; 1357 return err;
1364 1358
1365 next.vid = val & GLOBAL_VTU_VID_MASK;
1366 next.valid = !!(val & GLOBAL_VTU_VID_VALID);
1367
1368 if (next.valid) { 1359 if (next.valid) {
1369 err = mv88e6xxx_vtu_data_read(chip, &next); 1360 err = mv88e6xxx_vtu_data_read(chip, &next);
1370 if (err) 1361 if (err)
@@ -1410,7 +1401,9 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
1410 int (*cb)(struct switchdev_obj *obj)) 1401 int (*cb)(struct switchdev_obj *obj))
1411{ 1402{
1412 struct mv88e6xxx_chip *chip = ds->priv; 1403 struct mv88e6xxx_chip *chip = ds->priv;
1413 struct mv88e6xxx_vtu_entry next; 1404 struct mv88e6xxx_vtu_entry next = {
1405 .vid = chip->info->max_vid,
1406 };
1414 u16 pvid; 1407 u16 pvid;
1415 int err; 1408 int err;
1416 1409
@@ -1423,7 +1416,7 @@ static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
1423 if (err) 1416 if (err)
1424 goto unlock; 1417 goto unlock;
1425 1418
1426 err = _mv88e6xxx_vtu_vid_write(chip, GLOBAL_VTU_VID_MASK); 1419 err = mv88e6xxx_g1_vtu_vid_write(chip, &next);
1427 if (err) 1420 if (err)
1428 goto unlock; 1421 goto unlock;
1429 1422
@@ -1464,13 +1457,16 @@ static int _mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1464 struct mv88e6xxx_vtu_entry *entry) 1457 struct mv88e6xxx_vtu_entry *entry)
1465{ 1458{
1466 u16 op = GLOBAL_VTU_OP_VTU_LOAD_PURGE; 1459 u16 op = GLOBAL_VTU_OP_VTU_LOAD_PURGE;
1467 u16 reg = 0;
1468 int err; 1460 int err;
1469 1461
1470 err = mv88e6xxx_g1_vtu_op_wait(chip); 1462 err = mv88e6xxx_g1_vtu_op_wait(chip);
1471 if (err) 1463 if (err)
1472 return err; 1464 return err;
1473 1465
1466 err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
1467 if (err)
1468 return err;
1469
1474 if (!entry->valid) 1470 if (!entry->valid)
1475 goto loadpurge; 1471 goto loadpurge;
1476 1472
@@ -1496,14 +1492,7 @@ static int _mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1496 op |= (entry->fid & 0xf0) << 8; 1492 op |= (entry->fid & 0xf0) << 8;
1497 op |= entry->fid & 0xf; 1493 op |= entry->fid & 0xf;
1498 } 1494 }
1499
1500 reg = GLOBAL_VTU_VID_VALID;
1501loadpurge: 1495loadpurge:
1502 reg |= entry->vid & GLOBAL_VTU_VID_MASK;
1503 err = mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID, reg);
1504 if (err)
1505 return err;
1506
1507 return mv88e6xxx_g1_vtu_op(chip, op); 1496 return mv88e6xxx_g1_vtu_op(chip, op);
1508} 1497}
1509 1498
@@ -1513,7 +1502,6 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
1513 struct mv88e6xxx_vtu_entry next = { 1502 struct mv88e6xxx_vtu_entry next = {
1514 .sid = sid, 1503 .sid = sid,
1515 }; 1504 };
1516 u16 val;
1517 int err; 1505 int err;
1518 1506
1519 err = mv88e6xxx_g1_vtu_op_wait(chip); 1507 err = mv88e6xxx_g1_vtu_op_wait(chip);
@@ -1532,12 +1520,10 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
1532 if (err) 1520 if (err)
1533 return err; 1521 return err;
1534 1522
1535 err = mv88e6xxx_g1_read(chip, GLOBAL_VTU_VID, &val); 1523 err = mv88e6xxx_g1_vtu_vid_read(chip, &next);
1536 if (err) 1524 if (err)
1537 return err; 1525 return err;
1538 1526
1539 next.valid = !!(val & GLOBAL_VTU_VID_VALID);
1540
1541 if (next.valid) { 1527 if (next.valid) {
1542 err = mv88e6xxx_stu_data_read(chip, &next); 1528 err = mv88e6xxx_stu_data_read(chip, &next);
1543 if (err) 1529 if (err)
@@ -1551,7 +1537,6 @@ static int _mv88e6xxx_stu_getnext(struct mv88e6xxx_chip *chip, u8 sid,
1551static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip, 1537static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip,
1552 struct mv88e6xxx_vtu_entry *entry) 1538 struct mv88e6xxx_vtu_entry *entry)
1553{ 1539{
1554 u16 reg = 0;
1555 int err; 1540 int err;
1556 1541
1557 err = mv88e6xxx_g1_vtu_op_wait(chip); 1542 err = mv88e6xxx_g1_vtu_op_wait(chip);
@@ -1565,10 +1550,8 @@ static int _mv88e6xxx_stu_loadpurge(struct mv88e6xxx_chip *chip,
1565 err = mv88e6xxx_stu_data_write(chip, entry); 1550 err = mv88e6xxx_stu_data_write(chip, entry);
1566 if (err) 1551 if (err)
1567 return err; 1552 return err;
1568
1569 reg = GLOBAL_VTU_VID_VALID;
1570loadpurge: 1553loadpurge:
1571 err = mv88e6xxx_g1_write(chip, GLOBAL_VTU_VID, reg); 1554 err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
1572 if (err) 1555 if (err)
1573 return err; 1556 return err;
1574 1557
@@ -1582,7 +1565,9 @@ loadpurge:
1582static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) 1565static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1583{ 1566{
1584 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); 1567 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
1585 struct mv88e6xxx_vtu_entry vlan; 1568 struct mv88e6xxx_vtu_entry vlan = {
1569 .vid = chip->info->max_vid,
1570 };
1586 int i, err; 1571 int i, err;
1587 1572
1588 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); 1573 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
@@ -1597,7 +1582,7 @@ static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1597 } 1582 }
1598 1583
1599 /* Set every FID bit used by the VLAN entries */ 1584 /* Set every FID bit used by the VLAN entries */
1600 err = _mv88e6xxx_vtu_vid_write(chip, GLOBAL_VTU_VID_MASK); 1585 err = mv88e6xxx_g1_vtu_vid_write(chip, &vlan);
1601 if (err) 1586 if (err)
1602 return err; 1587 return err;
1603 1588
@@ -1681,7 +1666,9 @@ static int _mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1681 if (!vid) 1666 if (!vid)
1682 return -EINVAL; 1667 return -EINVAL;
1683 1668
1684 err = _mv88e6xxx_vtu_vid_write(chip, vid - 1); 1669 entry->vid = vid - 1;
1670 entry->valid = false;
1671 err = mv88e6xxx_g1_vtu_vid_write(chip, entry);
1685 if (err) 1672 if (err)
1686 return err; 1673 return err;
1687 1674
@@ -1706,7 +1693,9 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1706 u16 vid_begin, u16 vid_end) 1693 u16 vid_begin, u16 vid_end)
1707{ 1694{
1708 struct mv88e6xxx_chip *chip = ds->priv; 1695 struct mv88e6xxx_chip *chip = ds->priv;