diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2019-05-06 06:04:12 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2019-05-06 06:04:12 -0400 |
| commit | fb4e0592654adb31bc6f3a738d6499b816a655d6 (patch) | |
| tree | e6edaf18cf3a7f49e93fb51de5a47f4b9e786f53 /drivers/net | |
| parent | 471ba0e686cb13752bc1ff3216c54b69a2d250ea (diff) | |
| parent | 16e32c3cde7763ab875b9030b443ecbc8e352d8a (diff) | |
Merge tag 'irqchip-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into irq/core
Pull irqchip updates from Marc Zyngier
- The huge (and terrifying) TI INTR/INTA set of drivers
- Rewrite of the stm32mp1-exti driver as a platform driver
- Update the IOMMU MSI mapping API to be RT friendly
- A number of cleanups and other low impact fixes
Diffstat (limited to 'drivers/net')
127 files changed, 1225 insertions, 855 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 5e4ca082cfcd..7a96d168efc4 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
| @@ -216,8 +216,8 @@ config GENEVE | |||
| 216 | 216 | ||
| 217 | config GTP | 217 | config GTP |
| 218 | tristate "GPRS Tunneling Protocol datapath (GTP-U)" | 218 | tristate "GPRS Tunneling Protocol datapath (GTP-U)" |
| 219 | depends on INET && NET_UDP_TUNNEL | 219 | depends on INET |
| 220 | select NET_IP_TUNNEL | 220 | select NET_UDP_TUNNEL |
| 221 | ---help--- | 221 | ---help--- |
| 222 | This allows one to create gtp virtual interfaces that provide | 222 | This allows one to create gtp virtual interfaces that provide |
| 223 | the GPRS Tunneling Protocol datapath (GTP-U). This tunneling protocol | 223 | the GPRS Tunneling Protocol datapath (GTP-U). This tunneling protocol |
diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c index 2f120b2ffef0..4985268e2273 100644 --- a/drivers/net/bonding/bond_sysfs_slave.c +++ b/drivers/net/bonding/bond_sysfs_slave.c | |||
| @@ -55,7 +55,9 @@ static SLAVE_ATTR_RO(link_failure_count); | |||
| 55 | 55 | ||
| 56 | static ssize_t perm_hwaddr_show(struct slave *slave, char *buf) | 56 | static ssize_t perm_hwaddr_show(struct slave *slave, char *buf) |
| 57 | { | 57 | { |
| 58 | return sprintf(buf, "%pM\n", slave->perm_hwaddr); | 58 | return sprintf(buf, "%*phC\n", |
| 59 | slave->dev->addr_len, | ||
| 60 | slave->perm_hwaddr); | ||
| 59 | } | 61 | } |
| 60 | static SLAVE_ATTR_RO(perm_hwaddr); | 62 | static SLAVE_ATTR_RO(perm_hwaddr); |
| 61 | 63 | ||
diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c index dce84a2a65c7..c44b2822e4dd 100644 --- a/drivers/net/dsa/mv88e6xxx/port.c +++ b/drivers/net/dsa/mv88e6xxx/port.c | |||
| @@ -427,18 +427,22 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port, | |||
| 427 | return 0; | 427 | return 0; |
| 428 | 428 | ||
| 429 | lane = mv88e6390x_serdes_get_lane(chip, port); | 429 | lane = mv88e6390x_serdes_get_lane(chip, port); |
| 430 | if (lane < 0) | 430 | if (lane < 0 && lane != -ENODEV) |
| 431 | return lane; | 431 | return lane; |
| 432 | 432 | ||
| 433 | if (chip->ports[port].serdes_irq) { | 433 | if (lane >= 0) { |
| 434 | err = mv88e6390_serdes_irq_disable(chip, port, lane); | 434 | if (chip->ports[port].serdes_irq) { |
| 435 | err = mv88e6390_serdes_irq_disable(chip, port, lane); | ||
| 436 | if (err) | ||
| 437 | return err; | ||
| 438 | } | ||
| 439 | |||
| 440 | err = mv88e6390x_serdes_power(chip, port, false); | ||
| 435 | if (err) | 441 | if (err) |
| 436 | return err; | 442 | return err; |
| 437 | } | 443 | } |
| 438 | 444 | ||
| 439 | err = mv88e6390x_serdes_power(chip, port, false); | 445 | chip->ports[port].cmode = 0; |
| 440 | if (err) | ||
| 441 | return err; | ||
| 442 | 446 | ||
| 443 | if (cmode) { | 447 | if (cmode) { |
| 444 | err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®); | 448 | err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®); |
| @@ -452,6 +456,12 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port, | |||
| 452 | if (err) | 456 | if (err) |
| 453 | return err; | 457 | return err; |
| 454 | 458 | ||
| 459 | chip->ports[port].cmode = cmode; | ||
| 460 | |||
| 461 | lane = mv88e6390x_serdes_get_lane(chip, port); | ||
| 462 | if (lane < 0) | ||
| 463 | return lane; | ||
| 464 | |||
| 455 | err = mv88e6390x_serdes_power(chip, port, true); | 465 | err = mv88e6390x_serdes_power(chip, port, true); |
| 456 | if (err) | 466 | if (err) |
| 457 | return err; | 467 | return err; |
| @@ -463,8 +473,6 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port, | |||
| 463 | } | 473 | } |
| 464 | } | 474 | } |
| 465 | 475 | ||
| 466 | chip->ports[port].cmode = cmode; | ||
| 467 | |||
| 468 | return 0; | 476 | return 0; |
| 469 | } | 477 | } |
| 470 | 478 | ||
diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c index 576b37d12a63..c4fa400efdcc 100644 --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c | |||
| @@ -481,6 +481,155 @@ qca8k_port_set_status(struct qca8k_priv *priv, int port, int enable) | |||
| 481 | qca8k_reg_clear(priv, QCA8K_REG_PORT_STATUS(port), mask); | 481 | qca8k_reg_clear(priv, QCA8K_REG_PORT_STATUS(port), mask); |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | static u32 | ||
| 485 | qca8k_port_to_phy(int port) | ||
| 486 | { | ||
| 487 | /* From Andrew Lunn: | ||
| 488 | * Port 0 has no internal phy. | ||
| 489 | * Port 1 has an internal PHY at MDIO address 0. | ||
| 490 | * Port 2 has an internal PHY at MDIO address 1. | ||
| 491 | * ... | ||
| 492 | * Port 5 has an internal PHY at MDIO address 4. | ||
| 493 | * Port 6 has no internal PHY. | ||
| 494 | */ | ||
| 495 | |||
| 496 | return port - 1; | ||
| 497 | } | ||
| 498 | |||
| 499 | static int | ||
| 500 | qca8k_mdio_write(struct qca8k_priv *priv, int port, u32 regnum, u16 data) | ||
| 501 | { | ||
| 502 | u32 phy, val; | ||
| 503 | |||
| 504 | if (regnum >= QCA8K_MDIO_MASTER_MAX_REG) | ||
| 505 | return -EINVAL; | ||
| 506 | |||
| 507 | /* callee is responsible for not passing bad ports, | ||
| 508 | * but we still would like to make spills impossible. | ||
| 509 | */ | ||
| 510 | phy = qca8k_port_to_phy(port) % PHY_MAX_ADDR; | ||
| 511 | val = QCA8K_MDIO_MASTER_BUSY | QCA8K_MDIO_MASTER_EN | | ||
| 512 | QCA8K_MDIO_MASTER_WRITE | QCA8K_MDIO_MASTER_PHY_ADDR(phy) | | ||
| 513 | QCA8K_MDIO_MASTER_REG_ADDR(regnum) | | ||
| 514 | QCA8K_MDIO_MASTER_DATA(data); | ||
| 515 | |||
| 516 | qca8k_write(priv, QCA8K_MDIO_MASTER_CTRL, val); | ||
| 517 | |||
| 518 | return qca8k_busy_wait(priv, QCA8K_MDIO_MASTER_CTRL, | ||
| 519 | QCA8K_MDIO_MASTER_BUSY); | ||
| 520 | } | ||
| 521 | |||
| 522 | static int | ||
| 523 | qca8k_mdio_read(struct qca8k_priv *priv, int port, u32 regnum) | ||
| 524 | { | ||
| 525 | u32 phy, val; | ||
| 526 | |||
| 527 | if (regnum >= QCA8K_MDIO_MASTER_MAX_REG) | ||
| 528 | return -EINVAL; | ||
| 529 | |||
| 530 | /* callee is responsible for not passing bad ports, | ||
| 531 | * but we still would like to make spills impossible. | ||
| 532 | */ | ||
| 533 | phy = qca8k_port_to_phy(port) % PHY_MAX_ADDR; | ||
| 534 | val = QCA8K_MDIO_MASTER_BUSY | QCA8K_MDIO_MASTER_EN | | ||
| 535 | QCA8K_MDIO_MASTER_READ | QCA8K_MDIO_MASTER_PHY_ADDR(phy) | | ||
| 536 | QCA8K_MDIO_MASTER_REG_ADDR(regnum); | ||
| 537 | |||
| 538 | qca8k_write(priv, QCA8K_MDIO_MASTER_CTRL, val); | ||
| 539 | |||
| 540 | if (qca8k_busy_wait(priv, QCA8K_MDIO_MASTER_CTRL, | ||
| 541 | QCA8K_MDIO_MASTER_BUSY)) | ||
| 542 | return -ETIMEDOUT; | ||
| 543 | |||
| 544 | val = (qca8k_read(priv, QCA8K_MDIO_MASTER_CTRL) & | ||
| 545 | QCA8K_MDIO_MASTER_DATA_MASK); | ||
| 546 | |||
| 547 | return val; | ||
| 548 | } | ||
| 549 | |||
| 550 | static int | ||
| 551 | qca8k_phy_write(struct dsa_switch *ds, int port, int regnum, u16 data) | ||
| 552 | { | ||
| 553 | struct qca8k_priv *priv = ds->priv; | ||
| 554 | |||
| 555 | return qca8k_mdio_write(priv, port, regnum, data); | ||
| 556 | } | ||
| 557 | |||
| 558 | static int | ||
| 559 | qca8k_phy_read(struct dsa_switch *ds, int port, int regnum) | ||
| 560 | { | ||
| 561 | struct qca8k_priv *priv = ds->priv; | ||
| 562 | int ret; | ||
| 563 | |||
| 564 | ret = qca8k_mdio_read(priv, port, regnum); | ||
| 565 | |||
| 566 | if (ret < 0) | ||
| 567 | return 0xffff; | ||
| 568 | |||
| 569 | return ret; | ||
| 570 | } | ||
| 571 | |||
| 572 | static int | ||
| 573 | qca8k_setup_mdio_bus(struct qca8k_priv *priv) | ||
| 574 | { | ||
| 575 | u32 internal_mdio_mask = 0, external_mdio_mask = 0, reg; | ||
| 576 | struct device_node *ports, *port; | ||
| 577 | int err; | ||
| 578 | |||
| 579 | ports = of_get_child_by_name(priv->dev->of_node, "ports"); | ||
| 580 | if (!ports) | ||
| 581 | return -EINVAL; | ||
| 582 | |||
| 583 | for_each_available_child_of_node(ports, port) { | ||
| 584 | err = of_property_read_u32(port, "reg", ®); | ||
| 585 | if (err) | ||
| 586 | return err; | ||
| 587 | |||
| 588 | if (!dsa_is_user_port(priv->ds, reg)) | ||
| 589 | continue; | ||
| 590 | |||
| 591 | if (of_property_read_bool(port, "phy-handle")) | ||
| 592 | external_mdio_mask |= BIT(reg); | ||
| 593 | else | ||
| 594 | internal_mdio_mask |= BIT(reg); | ||
| 595 | } | ||
| 596 | |||
| 597 | if (!external_mdio_mask && !internal_mdio_mask) { | ||
| 598 | dev_err(priv->dev, "no PHYs are defined.\n"); | ||
| 599 | return -EINVAL; | ||
| 600 | } | ||
| 601 | |||
| 602 | /* The QCA8K_MDIO_MASTER_EN Bit, which grants access to PHYs through | ||
| 603 | * the MDIO_MASTER register also _disconnects_ the external MDC | ||
| 604 | * passthrough to the internal PHYs. It's not possible to use both | ||
| 605 | * configurations at the same time! | ||
| 606 | * | ||
| 607 | * Because this came up during the review process: | ||
| 608 | * If the external mdio-bus driver is capable magically disabling | ||
| 609 | * the QCA8K_MDIO_MASTER_EN and mutex/spin-locking out the qca8k's | ||
| 610 | * accessors for the time being, it would be possible to pull this | ||
| 611 | * off. | ||
| 612 | */ | ||
| 613 | if (!!external_mdio_mask && !!internal_mdio_mask) { | ||
| 614 | dev_err(priv->dev, "either internal or external mdio bus configuration is supported.\n"); | ||
| 615 | return -EINVAL; | ||
| 616 | } | ||
| 617 | |||
| 618 | if (external_mdio_mask) { | ||
| 619 | /* Make sure to disable the internal mdio bus in cases | ||
| 620 | * a dt-overlay and driver reload changed the configuration | ||
| 621 | */ | ||
| 622 | |||
| 623 | qca8k_reg_clear(priv, QCA8K_MDIO_MASTER_CTRL, | ||
| 624 | QCA8K_MDIO_MASTER_EN); | ||
| 625 | return 0; | ||
| 626 | } | ||
| 627 | |||
| 628 | priv->ops.phy_read = qca8k_phy_read; | ||
| 629 | priv->ops.phy_write = qca8k_phy_write; | ||
| 630 | return 0; | ||
| 631 | } | ||
| 632 | |||
| 484 | static int | 633 | static int |
| 485 | qca8k_setup(struct dsa_switch *ds) | 634 | qca8k_setup(struct dsa_switch *ds) |
| 486 | { | 635 | { |
| @@ -502,6 +651,10 @@ qca8k_setup(struct dsa_switch *ds) | |||
| 502 | if (IS_ERR(priv->regmap)) | 651 | if (IS_ERR(priv->regmap)) |
| 503 | pr_warn("regmap initialization failed"); | 652 | pr_warn("regmap initialization failed"); |
| 504 | 653 | ||
| 654 | ret = qca8k_setup_mdio_bus(priv); | ||
| 655 | if (ret) | ||
| 656 | return ret; | ||
| 657 | |||
| 505 | /* Initialize CPU port pad mode (xMII type, delays...) */ | 658 | /* Initialize CPU port pad mode (xMII type, delays...) */ |
| 506 | phy_mode = of_get_phy_mode(ds->ports[QCA8K_CPU_PORT].dn); | 659 | phy_mode = of_get_phy_mode(ds->ports[QCA8K_CPU_PORT].dn); |
| 507 | if (phy_mode < 0) { | 660 | if (phy_mode < 0) { |
| @@ -624,22 +777,6 @@ qca8k_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phy) | |||
| 624 | qca8k_port_set_status(priv, port, 1); | 777 | qca8k_port_set_status(priv, port, 1); |
| 625 | } | 778 | } |
| 626 | 779 | ||
| 627 | static int | ||
| 628 | qca8k_phy_read(struct dsa_switch *ds, int phy, int regnum) | ||
| 629 | { | ||
| 630 | struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; | ||
| 631 | |||
| 632 | return mdiobus_read(priv->bus, phy, regnum); | ||
| 633 | } | ||
| 634 | |||
| 635 | static int | ||
| 636 | qca8k_phy_write(struct dsa_switch *ds, int phy, int regnum, u16 val) | ||
| 637 | { | ||
| 638 | struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv; | ||
| 639 | |||
| 640 | return mdiobus_write(priv->bus, phy, regnum, val); | ||
| 641 | } | ||
| 642 | |||
| 643 | static void | 780 | static void |
| 644 | qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data) | 781 | qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *data) |
| 645 | { | 782 | { |
| @@ -879,8 +1016,6 @@ static const struct dsa_switch_ops qca8k_switch_ops = { | |||
| 879 | .setup = qca8k_setup, | 1016 | .setup = qca8k_setup, |
| 880 | .adjust_link = qca8k_adjust_link, | 1017 | .adjust_link = qca8k_adjust_link, |
| 881 | .get_strings = qca8k_get_strings, | 1018 | .get_strings = qca8k_get_strings, |
| 882 | .phy_read = qca8k_phy_read, | ||
| 883 | .phy_write = qca8k_phy_write, | ||
| 884 | .get_ethtool_stats = qca8k_get_ethtool_stats, | 1019 | .get_ethtool_stats = qca8k_get_ethtool_stats, |
| 885 | .get_sset_count = qca8k_get_sset_count, | 1020 | .get_sset_count = qca8k_get_sset_count, |
| 886 | .get_mac_eee = qca8k_get_mac_eee, | 1021 | .get_mac_eee = qca8k_get_mac_eee, |
| @@ -923,7 +1058,8 @@ qca8k_sw_probe(struct mdio_device *mdiodev) | |||
| 923 | return -ENOMEM; | 1058 | return -ENOMEM; |
| 924 | 1059 | ||
| 925 | priv->ds->priv = priv; | 1060 | priv->ds->priv = priv; |
| 926 | priv->ds->ops = &qca8k_switch_ops; | 1061 | priv->ops = qca8k_switch_ops; |
| 1062 | priv->ds->ops = &priv->ops; | ||
| 927 | mutex_init(&priv->reg_mutex); | 1063 | mutex_init(&priv->reg_mutex); |
| 928 | dev_set_drvdata(&mdiodev->dev, priv); | 1064 | dev_set_drvdata(&mdiodev->dev, priv); |
| 929 | 1065 | ||
diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h index d146e54c8a6c..249fd62268e5 100644 --- a/drivers/net/dsa/qca8k.h +++ b/drivers/net/dsa/qca8k.h | |||
| @@ -49,6 +49,18 @@ | |||
| 49 | #define QCA8K_MIB_FLUSH BIT(24) | 49 | #define QCA8K_MIB_FLUSH BIT(24) |
| 50 | #define QCA8K_MIB_CPU_KEEP BIT(20) | 50 | #define QCA8K_MIB_CPU_KEEP BIT(20) |
| 51 | #define QCA8K_MIB_BUSY BIT(17) | 51 | #define QCA8K_MIB_BUSY BIT(17) |
| 52 | #define QCA8K_MDIO_MASTER_CTRL 0x3c | ||
| 53 | #define QCA8K_MDIO_MASTER_BUSY BIT(31) | ||
| 54 | #define QCA8K_MDIO_MASTER_EN BIT(30) | ||
| 55 | #define QCA8K_MDIO_MASTER_READ BIT(27) | ||
| 56 | #define QCA8K_MDIO_MASTER_WRITE 0 | ||
| 57 | #define QCA8K_MDIO_MASTER_SUP_PRE BIT(26) | ||
| 58 | #define QCA8K_MDIO_MASTER_PHY_ADDR(x) ((x) << 21) | ||
| 59 | #define QCA8K_MDIO_MASTER_REG_ADDR(x) ((x) << 16) | ||
| 60 | #define QCA8K_MDIO_MASTER_DATA(x) (x) | ||
| 61 | #define QCA8K_MDIO_MASTER_DATA_MASK GENMASK(15, 0) | ||
| 62 | #define QCA8K_MDIO_MASTER_MAX_PORTS 5 | ||
| 63 | #define QCA8K_MDIO_MASTER_MAX_REG 32 | ||
| 52 | #define QCA8K_GOL_MAC_ADDR0 0x60 | 64 | #define QCA8K_GOL_MAC_ADDR0 0x60 |
| 53 | #define QCA8K_GOL_MAC_ADDR1 0x64 | 65 | #define QCA8K_GOL_MAC_ADDR1 0x64 |
| 54 | #define QCA8K_REG_PORT_STATUS(_i) (0x07c + (_i) * 4) | 66 | #define QCA8K_REG_PORT_STATUS(_i) (0x07c + (_i) * 4) |
| @@ -169,6 +181,7 @@ struct qca8k_priv { | |||
| 169 | struct dsa_switch *ds; | 181 | struct dsa_switch *ds; |
| 170 | struct mutex reg_mutex; | 182 | struct mutex reg_mutex; |
| 171 | struct device *dev; | 183 | struct device *dev; |
| 184 | struct dsa_switch_ops ops; | ||
| 172 | }; | 185 | }; |
| 173 | 186 | ||
| 174 | struct qca8k_mib_desc { | 187 | struct qca8k_mib_desc { |
diff --git a/drivers/net/ethernet/3com/3c515.c b/drivers/net/ethernet/3com/3c515.c index 808abb6b3671..b15752267c8d 100644 --- a/drivers/net/ethernet/3com/3c515.c +++ b/drivers/net/ethernet/3com/3c515.c | |||
| @@ -1521,7 +1521,7 @@ static void update_stats(int ioaddr, struct net_device *dev) | |||
| 1521 | static void set_rx_mode(struct net_device *dev) | 1521 | static void set_rx_mode(struct net_device *dev) |
| 1522 | { | 1522 | { |
| 1523 | int ioaddr = dev->base_addr; | 1523 | int ioaddr = dev->base_addr; |
| 1524 | short new_mode; | 1524 | unsigned short new_mode; |
| 1525 | 1525 | ||
| 1526 | if (dev->flags & IFF_PROMISC) { | 1526 | if (dev->flags & IFF_PROMISC) { |
| 1527 | if (corkscrew_debug > 3) | 1527 | if (corkscrew_debug > 3) |
diff --git a/drivers/net/ethernet/8390/mac8390.c b/drivers/net/ethernet/8390/mac8390.c index 342ae08ec3c2..d60a86aa8aa8 100644 --- a/drivers/net/ethernet/8390/mac8390.c +++ b/drivers/net/ethernet/8390/mac8390.c | |||
| @@ -153,8 +153,6 @@ static void dayna_block_input(struct net_device *dev, int count, | |||
| 153 | static void dayna_block_output(struct net_device *dev, int count, | 153 | static void dayna_block_output(struct net_device *dev, int count, |
| 154 | const unsigned char *buf, int start_page); | 154 | const unsigned char *buf, int start_page); |
| 155 | 155 | ||
| 156 | #define memcmp_withio(a, b, c) memcmp((a), (void *)(b), (c)) | ||
| 157 | |||
| 158 | /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */ | 156 | /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */ |
| 159 | static void slow_sane_get_8390_hdr(struct net_device *dev, | 157 | static void slow_sane_get_8390_hdr(struct net_device *dev, |
| 160 | struct e8390_pkt_hdr *hdr, int ring_page); | 158 | struct e8390_pkt_hdr *hdr, int ring_page); |
| @@ -233,19 +231,26 @@ static enum mac8390_type mac8390_ident(struct nubus_rsrc *fres) | |||
| 233 | 231 | ||
| 234 | static enum mac8390_access mac8390_testio(unsigned long membase) | 232 | static enum mac8390_access mac8390_testio(unsigned long membase) |
| 235 | { | 233 | { |
| 236 | unsigned long outdata = 0xA5A0B5B0; | 234 | u32 outdata = 0xA5A0B5B0; |
| 237 | unsigned long indata = 0x00000000; | 235 | u32 indata = 0; |
| 236 | |||
| 238 | /* Try writing 32 bits */ | 237 | /* Try writing 32 bits */ |
| 239 | memcpy_toio((void __iomem *)membase, &outdata, 4); | 238 | nubus_writel(outdata, membase); |
| 240 | /* Now compare them */ | 239 | /* Now read it back */ |
| 241 | if (memcmp_withio(&outdata, membase, 4) == 0) | 240 | indata = nubus_readl(membase); |
| 241 | if (outdata == indata) | ||
| 242 | return ACCESS_32; | 242 | return ACCESS_32; |
| 243 | |||
| 244 | outdata = 0xC5C0D5D0; | ||
| 245 | indata = 0; | ||
| 246 | |||
| 243 | /* Write 16 bit output */ | 247 | /* Write 16 bit output */ |
| 244 | word_memcpy_tocard(membase, &outdata, 4); | 248 | word_memcpy_tocard(membase, &outdata, 4); |
| 245 | /* Now read it back */ | 249 | /* Now read it back */ |
| 246 | word_memcpy_fromcard(&indata, membase, 4); | 250 | word_memcpy_fromcard(&indata, membase, 4); |
| 247 | if (outdata == indata) | 251 | if (outdata == indata) |
| 248 | return ACCESS_16; | 252 | return ACCESS_16; |
| 253 | |||
| 249 | return ACCESS_UNKNOWN; | 254 | return ACCESS_UNKNOWN; |
| 250 | } | 255 | } |
| 251 | 256 | ||
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index 74550ccc7a20..e2ffb159cbe2 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c | |||
| @@ -186,11 +186,12 @@ static void aq_rx_checksum(struct aq_ring_s *self, | |||
| 186 | } | 186 | } |
| 187 | if (buff->is_ip_cso) { | 187 | if (buff->is_ip_cso) { |
| 188 | __skb_incr_checksum_unnecessary(skb); | 188 | __skb_incr_checksum_unnecessary(skb); |
| 189 | if (buff->is_udp_cso || buff->is_tcp_cso) | ||
| 190 | __skb_incr_checksum_unnecessary(skb); | ||
| 191 | } else { | 189 | } else { |
| 192 | skb->ip_summed = CHECKSUM_NONE; | 190 | skb->ip_summed = CHECKSUM_NONE; |
| 193 | } | 191 | } |
| 192 | |||
| 193 | if (buff->is_udp_cso || buff->is_tcp_cso) | ||
| 194 | __skb_incr_checksum_unnecessary(skb); | ||
| 194 | } | 195 | } |
| 195 | 196 | ||
| 196 | #define AQ_SKB_ALIGN SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) | 197 | #define AQ_SKB_ALIGN SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0bb9d7b3a2b6..4c586ba4364b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c | |||
| @@ -1133,6 +1133,8 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, | |||
| 1133 | tpa_info = &rxr->rx_tpa[agg_id]; | 1133 | tpa_info = &rxr->rx_tpa[agg_id]; |
| 1134 | 1134 | ||
| 1135 | if (unlikely(cons != rxr->rx_next_cons)) { | 1135 | if (unlikely(cons != rxr->rx_next_cons)) { |
| 1136 | netdev_warn(bp->dev, "TPA cons %x != expected cons %x\n", | ||
| 1137 | cons, rxr->rx_next_cons); | ||
| 1136 | bnxt_sched_reset(bp, rxr); | 1138 | bnxt_sched_reset(bp, rxr); |
| 1137 | return; | 1139 | return; |
| 1138 | } | 1140 | } |
| @@ -1585,15 +1587,17 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, | |||
| 1585 | } | 1587 | } |
| 1586 | 1588 | ||
| 1587 | cons = rxcmp->rx_cmp_opaque; | 1589 | cons = rxcmp->rx_cmp_opaque; |
| 1588 | rx_buf = &rxr->rx_buf_ring[cons]; | ||
| 1589 | data = rx_buf->data; | ||
| 1590 | data_ptr = rx_buf->data_ptr; | ||
| 1591 | if (unlikely(cons != rxr->rx_next_cons)) { | 1590 | if (unlikely(cons != rxr->rx_next_cons)) { |
| 1592 | int rc1 = bnxt_discard_rx(bp, cpr, raw_cons, rxcmp); | 1591 | int rc1 = bnxt_discard_rx(bp, cpr, raw_cons, rxcmp); |
| 1593 | 1592 | ||
| 1593 | netdev_warn(bp->dev, "RX cons %x != expected cons %x\n", | ||
| 1594 | cons, rxr->rx_next_cons); | ||
| 1594 | bnxt_sched_reset(bp, rxr); | 1595 | bnxt_sched_reset(bp, rxr); |
| 1595 | return rc1; | 1596 | return rc1; |
| 1596 | } | 1597 | } |
| 1598 | rx_buf = &rxr->rx_buf_ring[cons]; | ||
| 1599 | data = rx_buf->data; | ||
| 1600 | data_ptr = rx_buf->data_ptr; | ||
| 1597 | prefetch(data_ptr); | 1601 | prefetch(data_ptr); |
| 1598 | 1602 | ||
| 1599 | misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1); | 1603 | misc = le32_to_cpu(rxcmp->rx_cmp_misc_v1); |
| @@ -1610,11 +1614,17 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, | |||
| 1610 | 1614 | ||
| 1611 | rx_buf->data = NULL; | 1615 | rx_buf->data = NULL; |
| 1612 | if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) { | 1616 | if (rxcmp1->rx_cmp_cfa_code_errors_v2 & RX_CMP_L2_ERRORS) { |
| 1617 | u32 rx_err = le32_to_cpu(rxcmp1->rx_cmp_cfa_code_errors_v2); | ||
| 1618 | |||
| 1613 | bnxt_reuse_rx_data(rxr, cons, data); | 1619 | bnxt_reuse_rx_data(rxr, cons, data); |
| 1614 | if (agg_bufs) | 1620 | if (agg_bufs) |
| 1615 | bnxt_reuse_rx_agg_bufs(cpr, cp_cons, agg_bufs); | 1621 | bnxt_reuse_rx_agg_bufs(cpr, cp_cons, agg_bufs); |
| 1616 | 1622 | ||
| 1617 | rc = -EIO; | 1623 | rc = -EIO; |
| 1624 | if (rx_err & RX_CMPL_ERRORS_BUFFER_ERROR_MASK) { | ||
| 1625 | netdev_warn(bp->dev, "RX buffer error %x\n", rx_err); | ||
| 1626 | bnxt_sched_reset(bp, rxr); | ||
| 1627 | } | ||
| 1618 | goto next_rx; | 1628 | goto next_rx; |
| 1619 | } | 1629 | } |
| 1620 | 1630 | ||
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 328373e0578f..060a6f386104 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
| @@ -4283,7 +4283,7 @@ static void tg3_power_down(struct tg3 *tp) | |||
| 4283 | pci_set_power_state(tp->pdev, PCI_D3hot); | 4283 | pci_set_power_state(tp->pdev, PCI_D3hot); |
| 4284 | } | 4284 | } |
| 4285 | 4285 | ||
| 4286 | static void tg3_aux_stat_to_speed_duplex(struct tg3 *tp, u32 val, u16 *speed, u8 *duplex) | 4286 | static void tg3_aux_stat_to_speed_duplex(struct tg3 *tp, u32 val, u32 *speed, u8 *duplex) |
| 4287 | { | 4287 | { |
| 4288 | switch (val & MII_TG3_AUX_STAT_SPDMASK) { | 4288 | switch (val & MII_TG3_AUX_STAT_SPDMASK) { |
| 4289 | case MII_TG3_AUX_STAT_10HALF: | 4289 | case MII_TG3_AUX_STAT_10HALF: |
| @@ -4787,7 +4787,7 @@ static int tg3_setup_copper_phy(struct tg3 *tp, bool force_reset) | |||
| 4787 | bool current_link_up; | 4787 | bool current_link_up; |
| 4788 | u32 bmsr, val; | 4788 | u32 bmsr, val; |
| 4789 | u32 lcl_adv, rmt_adv; | 4789 | u32 lcl_adv, rmt_adv; |
| 4790 | u16 current_speed; | 4790 | u32 current_speed; |
| 4791 | u8 current_duplex; | 4791 | u8 current_duplex; |
| 4792 | int i, err; | 4792 | int i, err; |
| 4793 | 4793 | ||
| @@ -5719,7 +5719,7 @@ out: | |||
| 5719 | static int tg3_setup_fiber_phy(struct tg3 *tp, bool force_reset) | 5719 | static int tg3_setup_fiber_phy(struct tg3 *tp, bool force_reset) |
| 5720 | { | 5720 | { |
| 5721 | u32 orig_pause_cfg; | 5721 | u32 orig_pause_cfg; |
| 5722 | u16 orig_active_speed; | 5722 | u32 orig_active_speed; |
| 5723 | u8 orig_active_duplex; | 5723 | u8 orig_active_duplex; |
| 5724 | u32 mac_status; | 5724 | u32 mac_status; |
| 5725 | bool current_link_up; | 5725 | bool current_link_up; |
| @@ -5823,7 +5823,7 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, bool force_reset) | |||
| 5823 | { | 5823 | { |
| 5824 | int err = 0; | 5824 | int err = 0; |
| 5825 | u32 bmsr, bmcr; | 5825 | u32 bmsr, bmcr; |
| 5826 | u16 current_speed = SPEED_UNKNOWN; | 5826 | u32 current_speed = SPEED_UNKNOWN; |
| 5827 | u8 current_duplex = DUPLEX_UNKNOWN; | 5827 | u8 current_duplex = DUPLEX_UNKNOWN; |
| 5828 | bool current_link_up = false; | 5828 | bool current_link_up = false; |
| 5829 | u32 local_adv, remote_adv, sgsr; | 5829 | u32 local_adv, remote_adv, sgsr; |
diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h index a772a33b685c..6953d0546acb 100644 --- a/drivers/net/ethernet/broadcom/tg3.h +++ b/drivers/net/ethernet/broadcom/tg3.h | |||
| @@ -2873,7 +2873,7 @@ struct tg3_tx_ring_info { | |||
| 2873 | struct tg3_link_config { | 2873 | struct tg3_link_config { |
| 2874 | /* Describes what we're trying to get. */ | 2874 | /* Describes what we're trying to get. */ |
| 2875 | u32 advertising; | 2875 | u32 advertising; |
| 2876 | u16 speed; | 2876 | u32 speed; |
| 2877 | u8 duplex; | 2877 | u8 duplex; |
| 2878 | u8 autoneg; | 2878 | u8 autoneg; |
| 2879 | u8 flowctrl; | 2879 | u8 flowctrl; |
| @@ -2882,7 +2882,7 @@ struct tg3_link_config { | |||
| 2882 | u8 active_flowctrl; | 2882 | u8 active_flowctrl; |
| 2883 | 2883 | ||
| 2884 | u8 active_duplex; | 2884 | u8 active_duplex; |
| 2885 | u16 active_speed; | 2885 | u32 active_speed; |
| 2886 | u32 rmt_adv; | 2886 | u32 rmt_adv; |
| 2887 | }; | 2887 | }; |
| 2888 | 2888 | ||
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index ad099fd01b45..3da2795e2486 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c | |||
| @@ -898,7 +898,9 @@ static void macb_tx_interrupt(struct macb_queue *queue) | |||
| 898 | 898 | ||
| 899 | /* First, update TX stats if needed */ | 899 | /* First, update TX stats if needed */ |
| 900 | if (skb) { | 900 | if (skb) { |
| 901 | if (gem_ptp_do_txstamp(queue, skb, desc) == 0) { | 901 | if (unlikely(skb_shinfo(skb)->tx_flags & |
| 902 | SKBTX_HW_TSTAMP) && | ||
| 903 | gem_ptp_do_txstamp(queue, skb, desc) == 0) { | ||
| 902 | /* skb now belongs to timestamp buffer | 904 | /* skb now belongs to timestamp buffer |
| 903 | * and will be removed later | 905 | * and will be removed later |
| 904 | */ | 906 | */ |
| @@ -3370,14 +3372,20 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, | |||
| 3370 | *hclk = devm_clk_get(&pdev->dev, "hclk"); | 3372 | *hclk = devm_clk_get(&pdev->dev, "hclk"); |
| 3371 | } | 3373 | } |
| 3372 | 3374 | ||
| 3373 | if (IS_ERR(*pclk)) { | 3375 | if (IS_ERR_OR_NULL(*pclk)) { |
| 3374 | err = PTR_ERR(*pclk); | 3376 | err = PTR_ERR(*pclk); |
| 3377 | if (!err) | ||
| 3378 | err = -ENODEV; | ||
| 3379 | |||
| 3375 | dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); | 3380 | dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); |
| 3376 | return err; | 3381 | return err; |
| 3377 | } | 3382 | } |
| 3378 | 3383 | ||
| 3379 | if (IS_ERR(*hclk)) { | 3384 | if (IS_ERR_OR_NULL(*hclk)) { |
| 3380 | err = PTR_ERR(*hclk); | 3385 | err = PTR_ERR(*hclk); |
| 3386 | if (!err) | ||
| 3387 | err = -ENODEV; | ||
| 3388 | |||
| 3381 | dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); | 3389 | dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); |
| 3382 | return err; | 3390 | return err; |
| 3383 | } | 3391 | } |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index aa2be4807191..28eac9056211 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c | |||
| @@ -1328,10 +1328,11 @@ int nicvf_stop(struct net_device *netdev) | |||
| 1328 | struct nicvf_cq_poll *cq_poll = NULL; | 1328 | struct nicvf_cq_poll *cq_poll = NULL; |
| 1329 | union nic_mbx mbx = {}; | 1329 | union nic_mbx mbx = {}; |
| 1330 | 1330 | ||
| 1331 | cancel_delayed_work_sync(&nic->link_change_work); | ||
| 1332 | |||
| 1333 | /* wait till all queued set_rx_mode tasks completes */ | 1331 | /* wait till all queued set_rx_mode tasks completes */ |
| 1334 | drain_workqueue(nic->nicvf_rx_mode_wq); | 1332 | if (nic->nicvf_rx_mode_wq) { |
| 1333 | cancel_delayed_work_sync(&nic->link_change_work); | ||
| 1334 | drain_workqueue(nic->nicvf_rx_mode_wq); | ||
| 1335 | } | ||
| 1335 | 1336 | ||
| 1336 | mbx.msg.msg = NIC_MBOX_MSG_SHUTDOWN; | 1337 | mbx.msg.msg = NIC_MBOX_MSG_SHUTDOWN; |
| 1337 | nicvf_send_msg_to_pf(nic, &mbx); | 1338 | nicvf_send_msg_to_pf(nic, &mbx); |
| @@ -1452,7 +1453,8 @@ int nicvf_open(struct net_device *netdev) | |||
| 1452 | struct nicvf_cq_poll *cq_poll = NULL; | 1453 | struct nicvf_cq_poll *cq_poll = NULL; |
| 1453 | 1454 | ||
| 1454 | /* wait till all queued set_rx_mode tasks completes if any */ | 1455 | /* wait till all queued set_rx_mode tasks completes if any */ |
| 1455 | drain_workqueue(nic->nicvf_rx_mode_wq); | 1456 | if (nic->nicvf_rx_mode_wq) |
| 1457 | drain_workqueue(nic->nicvf_rx_mode_wq); | ||
| 1456 | 1458 | ||
| 1457 | netif_carrier_off(netdev); | 1459 | netif_carrier_off(netdev); |
| 1458 | 1460 | ||
| @@ -1550,10 +1552,12 @@ int nicvf_open(struct net_device *netdev) | |||
| 1550 | /* Send VF config done msg to PF */ | 1552 | /* Send VF config done msg to PF */ |
| 1551 | nicvf_send_cfg_done(nic); | 1553 | nicvf_send_cfg_done(nic); |
| 1552 | 1554 | ||
| 1553 | INIT_DELAYED_WORK(&nic->link_change_work, | 1555 | if (nic->nicvf_rx_mode_wq) { |
| 1554 | nicvf_link_status_check_task); | 1556 | INIT_DELAYED_WORK(&nic->link_change_work, |
| 1555 | queue_delayed_work(nic->nicvf_rx_mode_wq, | 1557 | nicvf_link_status_check_task); |
| 1556 | &nic->link_change_work, 0); | 1558 | queue_delayed_work(nic->nicvf_rx_mode_wq, |
| 1559 | &nic->link_change_work, 0); | ||
| 1560 | } | ||
| 1557 | 1561 | ||
| 1558 | return 0; | 1562 | return 0; |
| 1559 | cleanup: | 1563 | cleanup: |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index 5b4d3badcb73..e246f9733bb8 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c | |||
| @@ -105,20 +105,19 @@ static inline struct pgcache *nicvf_alloc_page(struct nicvf *nic, | |||
| 105 | /* Check if page can be recycled */ | 105 | /* Check if page can be recycled */ |
| 106 | if (page) { | 106 | if (page) { |
| 107 | ref_count = page_ref_count(page); | 107 | ref_count = page_ref_count(page); |
| 108 | /* Check if this page has been used once i.e 'put_page' | 108 | /* This page can be recycled if internal ref_count and page's |
| 109 | * called after packet transmission i.e internal ref_count | 109 | * ref_count are equal, indicating that the page has been used |
| 110 | * and page's ref_count are equal i.e page can be recycled. | 110 | * once for packet transmission. For non-XDP mode, internal |
| 111 | * ref_count is always '1'. | ||
| 111 | */ | 112 | */ |
| 112 | if (rbdr->is_xdp && (ref_count == pgcache->ref_count)) | 113 | if (rbdr->is_xdp) { |
| 113 | pgcache->ref_count--; | 114 | if (ref_count == pgcache->ref_count) |
| 114 | else | 115 | pgcache->ref_count--; |
| 115 | page = NULL; | 116 | else |
| 116 | 117 | page = NULL; | |
| 117 | /* In non-XDP mode, page's ref_count needs to be '1' for it | 118 | } else if (ref_count != 1) { |
| 118 | * to be recycled. | ||
| 119 | */ | ||
| 120 | if (!rbdr->is_xdp && (ref_count != 1)) | ||
| 121 | page = NULL; | 119 | page = NULL; |
| 120 | } | ||
| 122 | } | 121 | } |
| 123 | 122 | ||
| 124 | if (!page) { | 123 | if (!page) { |
| @@ -365,11 +364,10 @@ static void nicvf_free_rbdr(struct nicvf *nic, struct rbdr *rbdr) | |||
| 365 | while (head < rbdr->pgcnt) { | 364 | while (head < rbdr->pgcnt) { |
| 366 | pgcache = &rbdr->pgcache[head]; | 365 | pgcache = &rbdr->pgcache[head]; |
| 367 | if (pgcache->page && page_ref_count(pgcache->page) != 0) { | 366 | if (pgcache->page && page_ref_count(pgcache->page) != 0) { |
| 368 | if (!rbdr->is_xdp) { | 367 | if (rbdr->is_xdp) { |
| 369 | put_page(pgcache->page); | 368 | page_ref_sub(pgcache->page, |
| 370 | continue; | 369 | pgcache->ref_count - 1); |
| 371 | } | 370 | } |
| 372 | page_ref_sub(pgcache->page, pgcache->ref_count - 1); | ||
| 373 | put_page(pgcache->page); | 371 | put_page(pgcache->page); |
| 374 | } | 372 | } |
| 375 | head++; | 373 | head++; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index 3130b43bba52..02959035ed3f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | |||
| @@ -2620,7 +2620,7 @@ static inline struct port_info *ethqset2pinfo(struct adapter *adap, int qset) | |||
| 2620 | } | 2620 | } |
| 2621 | 2621 | ||
| 2622 | /* should never happen! */ | 2622 | /* should never happen! */ |
| 2623 | BUG_ON(1); | 2623 | BUG(); |
| 2624 | return NULL; | 2624 | return NULL; |
| 2625 | } | 2625 | } |
| 2626 | 2626 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 88773ca58e6b..b3da81e90132 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c | |||
| @@ -476,7 +476,7 @@ static inline int get_buf_size(struct adapter *adapter, | |||
| 476 | break; | 476 | break; |
| 477 | 477 | ||
| 478 | default: | 478 | default: |
| 479 | BUG_ON(1); | 479 | BUG(); |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | return buf_size; | 482 | return buf_size; |
diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c index 74849be5f004..e2919005ead3 100644 --- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c +++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c | |||
| @@ -354,7 +354,10 @@ static struct cxgbi_ppm_pool *ppm_alloc_cpu_pool(unsigned int *total, | |||
| 354 | ppmax = max; | 354 | ppmax = max; |
| 355 | 355 | ||
| 356 | /* pool size must be multiple of unsigned long */ | 356 | /* pool size must be multiple of unsigned long */ |
| 357 | bmap = BITS_TO_LONGS(ppmax); | 357 | bmap = ppmax / BITS_PER_TYPE(unsigned long); |
| 358 | if (!bmap) | ||
| 359 | return NULL; | ||
| 360 | |||
| 358 | ppmax = (bmap * sizeof(unsigned long)) << 3; | 361 | ppmax = (bmap * sizeof(unsigned long)) << 3; |
| 359 | 362 | ||
| 360 | alloc_sz = sizeof(*pools) + sizeof(unsigned long) * bmap; | 363 | alloc_sz = sizeof(*pools) + sizeof(unsigned long) * bmap; |
| @@ -402,6 +405,10 @@ int cxgbi_ppm_init(void **ppm_pp, struct net_device *ndev, | |||
| 402 | if (reserve_factor) { | 405 | if (reserve_factor) { |
| 403 | ppmax_pool = ppmax / reserve_factor; | 406 | ppmax_pool = ppmax / reserve_factor; |
| 404 | pool = ppm_alloc_cpu_pool(&ppmax_pool, &pool_index_max); | 407 | pool = ppm_alloc_cpu_pool(&ppmax_pool, &pool_index_max); |
| 408 | if (!pool) { | ||
| 409 | ppmax_pool = 0; | ||
| 410 | reserve_factor = 0; | ||
| 411 | } | ||
| 405 | 412 | ||
| 406 | pr_debug("%s: ppmax %u, cpu total %u, per cpu %u.\n", | 413 | pr_debug("%s: ppmax %u, cpu total %u, per cpu %u.\n", |
| 407 | ndev->name, ppmax, ppmax_pool, pool_index_max); | 414 | ndev->name, ppmax, ppmax_pool, pool_index_max); |
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 2ba49e959c3f..dc339dc1adb2 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | |||
| @@ -815,6 +815,14 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) | |||
| 815 | */ | 815 | */ |
| 816 | queue_mapping = skb_get_queue_mapping(skb); | 816 | queue_mapping = skb_get_queue_mapping(skb); |
| 817 | fq = &priv->fq[queue_mapping]; | 817 | fq = &priv->fq[queue_mapping]; |
| 818 | |||
| 819 | fd_len = dpaa2_fd_get_len(&fd); | ||
| 820 | nq = netdev_get_tx_queue(net_dev, queue_mapping); | ||
| 821 | netdev_tx_sent_queue(nq, fd_len); | ||
| 822 | |||
| 823 | /* Everything that happens after this enqueues might race with | ||
| 824 | * the Tx confirmation callback for this frame | ||
| 825 | */ | ||
| 818 | for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { | 826 | for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { |
| 819 | err = priv->enqueue(priv, fq, &fd, 0); | 827 | err = priv->enqueue(priv, fq, &fd, 0); |
| 820 | if (err != -EBUSY) | 828 | if (err != -EBUSY) |
| @@ -825,13 +833,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) | |||
| 825 | percpu_stats->tx_errors++; | 833 | percpu_stats->tx_errors++; |
| 826 | /* Clean up everything, including freeing the skb */ | 834 | /* Clean up everything, including freeing the skb */ |
| 827 | free_tx_fd(priv, fq, &fd, false); | 835 | free_tx_fd(priv, fq, &fd, false); |
| 836 | netdev_tx_completed_queue(nq, 1, fd_len); | ||
| 828 | } else { | 837 | } else { |
| 829 | fd_len = dpaa2_fd_get_len(&fd); | ||
| 830 | percpu_stats->tx_packets++; | 838 | percpu_stats->tx_packets++; |
| 831 | percpu_stats->tx_bytes += fd_len; | 839 | percpu_stats->tx_bytes += fd_len; |
| 832 | |||
| 833 | nq = netdev_get_tx_queue(net_dev, queue_mapping); | ||
| 834 | netdev_tx_sent_queue(nq, fd_len); | ||
| 835 | } | 840 | } |
| 836 | 841 | ||
| 837 | return NETDEV_TX_OK; | 842 | return NETDEV_TX_OK; |
| @@ -1817,7 +1822,7 @@ static int dpaa2_eth_xdp_xmit_frame(struct net_device *net_dev, | |||
| 1817 | dpaa2_fd_set_format(&fd, dpaa2_fd_single); | 1822 | dpaa2_fd_set_format(&fd, dpaa2_fd_single); |
| 1818 | dpaa2_fd_set_ctrl(&fd, FD_CTRL_PTA); | 1823 | dpaa2_fd_set_ctrl(&fd, FD_CTRL_PTA); |
| 1819 | 1824 | ||
| 1820 | fq = &priv->fq[smp_processor_id()]; | 1825 | fq = &priv->fq[smp_processor_id() % dpaa2_eth_queue_count(priv)]; |
| 1821 | for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { | 1826 | for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { |
| 1822 | err = priv->enqueue(priv, fq, &fd, 0); | 1827 | err = priv->enqueue(priv, fq, &fd, 0); |
| 1823 | if (err != -EBUSY) | 1828 | if (err != -EBUSY) |
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c index 79d03f8ee7b1..c7fa97a7e1f4 100644 --- a/drivers/net/ethernet/hisilicon/hns/hnae.c +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c | |||
| @@ -150,7 +150,6 @@ out_buffer_fail: | |||
| 150 | /* free desc along with its attached buffer */ | 150 | /* free desc along with its attached buffer */ |
| 151 | static void hnae_free_desc(struct hnae_ring *ring) | 151 | static void hnae_free_desc(struct hnae_ring *ring) |
| 152 | { | 152 | { |
| 153 | hnae_free_buffers(ring); | ||
| 154 | dma_unmap_single(ring_to_dev(ring), ring->desc_dma_addr, | 153 | dma_unmap_single(ring_to_dev(ring), ring->desc_dma_addr, |
| 155 | ring->desc_num * sizeof(ring->desc[0]), | 154 | ring->desc_num * sizeof(ring->desc[0]), |
| 156 | ring_to_dma_dir(ring)); | 155 | ring_to_dma_dir(ring)); |
| @@ -183,6 +182,9 @@ static int hnae_alloc_desc(struct hnae_ring *ring) | |||
| 183 | /* fini ring, also free the buffer for the ring */ | 182 | /* fini ring, also free the buffer for the ring */ |
| 184 | static void hnae_fini_ring(struct hnae_ring *ring) | 183 | static void hnae_fini_ring(struct hnae_ring *ring) |
| 185 | { | 184 | { |
| 185 | if (is_rx_ring(ring)) | ||
| 186 | hnae_free_buffers(ring); | ||
| 187 | |||
| 186 | hnae_free_desc(ring); | 188 | hnae_free_desc(ring); |
| 187 | kfree(ring->desc_cb); | 189 | kfree(ring->desc_cb); |
| 188 | ring->desc_cb = NULL; | 190 | ring->desc_cb = NULL; |
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h index 08a750fb60c4..d6fb83437230 100644 --- a/drivers/net/ethernet/hisilicon/hns/hnae.h +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h | |||
| @@ -357,7 +357,7 @@ struct hnae_buf_ops { | |||
| 357 | }; | 357 | }; |
| 358 | 358 | ||
| 359 | struct hnae_queue { | 359 | struct hnae_queue { |
| 360 | void __iomem *io_base; | 360 | u8 __iomem *io_base; |
| 361 | phys_addr_t phy_base; | 361 | phys_addr_t phy_base; |
| 362 | struct hnae_ae_dev *dev; /* the device who use this queue */ | 362 | struct hnae_ae_dev *dev; /* the device who use this queue */ |
| 363 | struct hnae_ring rx_ring ____cacheline_internodealigned_in_smp; | 363 | struct hnae_ring rx_ring ____cacheline_internodealigned_in_smp; |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c index a97228c93831..6c0507921623 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | |||
| @@ -370,7 +370,7 @@ int hns_mac_clr_multicast(struct hns_mac_cb *mac_cb, int vfn) | |||
| 370 | static void hns_mac_param_get(struct mac_params *param, | 370 | static void hns_mac_param_get(struct mac_params *param, |
| 371 | struct hns_mac_cb *mac_cb) | 371 | struct hns_mac_cb *mac_cb) |
| 372 | { | 372 | { |
| 373 | param->vaddr = (void *)mac_cb->vaddr; | 373 | param->vaddr = mac_cb->vaddr; |
| 374 | param->mac_mode = hns_get_enet_interface(mac_cb); | 374 | param->mac_mode = hns_get_enet_interface(mac_cb); |
| 375 | ether_addr_copy(param->addr, mac_cb->addr_entry_idx[0].addr); | 375 | ether_addr_copy(param->addr, mac_cb->addr_entry_idx[0].addr); |
| 376 | param->mac_id = mac_cb->mac_id; | 376 | param->mac_id = mac_cb->mac_id; |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h index fbc75341bef7..22589799f1a5 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h | |||
| @@ -187,7 +187,7 @@ struct mac_statistics { | |||
| 187 | /*mac para struct ,mac get param from nic or dsaf when initialize*/ | 187 | /*mac para struct ,mac get param from nic or dsaf when initialize*/ |
| 188 | struct mac_params { | 188 | struct mac_params { |
| 189 | char addr[ETH_ALEN]; | 189 | char addr[ETH_ALEN]; |
| 190 | void *vaddr; /*virtual address*/ | 190 | u8 __iomem *vaddr; /*virtual address*/ |
| 191 | struct device *dev; | 191 | struct device *dev; |
| 192 | u8 mac_id; | 192 | u8 mac_id; |
| 193 | /**< Ethernet operation mode (MAC-PHY interface and speed) */ | 193 | /**< Ethernet operation mode (MAC-PHY interface and speed) */ |
| @@ -402,7 +402,7 @@ struct mac_driver { | |||
| 402 | enum mac_mode mac_mode; | 402 | enum mac_mode mac_mode; |
| 403 | u8 mac_id; | 403 | u8 mac_id; |
| 404 | struct hns_mac_cb *mac_cb; | 404 | struct hns_mac_cb *mac_cb; |
| 405 | void __iomem *io_base; | 405 | u8 __iomem *io_base; |
| 406 | unsigned int mac_en_flg;/*you'd better don't enable mac twice*/ | 406 | unsigned int mac_en_flg;/*you'd better don't enable mac twice*/ |
| 407 | unsigned int virt_dev_num; | 407 | unsigned int virt_dev_num; |
| 408 | struct device *dev; | 408 | struct device *dev; |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c index ac55db065f16..61eea6ac846f 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | |||
| @@ -1602,8 +1602,6 @@ static void hns_dsaf_set_mac_key( | |||
| 1602 | DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id); | 1602 | DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id); |
| 1603 | dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M, | 1603 | dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M, |
| 1604 | DSAF_TBL_TCAM_KEY_PORT_S, port); | 1604 | DSAF_TBL_TCAM_KEY_PORT_S, port); |
| 1605 | |||
| 1606 | mac_key->low.bits.port_vlan = le16_to_cpu(mac_key->low.bits.port_vlan); | ||
| 1607 | } | 1605 | } |
| 1608 | 1606 | ||
| 1609 | /** | 1607 | /** |
| @@ -1663,8 +1661,8 @@ int hns_dsaf_set_mac_uc_entry( | |||
| 1663 | /* default config dvc to 0 */ | 1661 | /* default config dvc to 0 */ |
| 1664 | mac_data.tbl_ucast_dvc = 0; | 1662 | mac_data.tbl_ucast_dvc = 0; |
| 1665 | mac_data.tbl_ucast_out_port = mac_entry->port_num; | 1663 | mac_data.tbl_ucast_out_port = mac_entry->port_num; |
| 1666 | tcam_data.tbl_tcam_data_high = cpu_to_le32(mac_key.high.val); | 1664 | tcam_data.tbl_tcam_data_high = mac_key.high.val; |
| 1667 | tcam_data.tbl_tcam_data_low = cpu_to_le32(mac_key.low.val); | 1665 | tcam_data.tbl_tcam_data_low = mac_key.low.val; |
| 1668 | 1666 | ||
| 1669 | hns_dsaf_tcam_uc_cfg(dsaf_dev, entry_index, &tcam_data, &mac_data); | 1667 | hns_dsaf_tcam_uc_cfg(dsaf_dev, entry_index, &tcam_data, &mac_data); |
| 1670 | 1668 | ||
| @@ -1786,9 +1784,6 @@ int hns_dsaf_add_mac_mc_port(struct dsaf_device *dsaf_dev, | |||
| 1786 | 0xff, | 1784 | 0xff, |
| 1787 | mc_mask); | 1785 | mc_mask); |
| 1788 | 1786 | ||
| 1789 | mask_key.high.val = le32_to_cpu(mask_key.high.val); | ||
| 1790 | mask_key.low.val = le32_to_cpu(mask_key.low.val); | ||
| 1791 | |||
| 1792 | pmask_key = (struct dsaf_tbl_tcam_data *)(&mask_key); | 1787 | pmask_key = (struct dsaf_tbl_tcam_data *)(&mask_key); |
| 1793 | } | 1788 | } |
| 1794 | 1789 | ||
| @@ -1840,8 +1835,8 @@ int hns_dsaf_add_mac_mc_port(struct dsaf_device *dsaf_dev, | |||
| 1840 | dsaf_dev->ae_dev.name, mac_key.high.val, | 1835 | dsaf_dev->ae_dev.name, mac_key.high.val, |
| 1841 | mac_key.low.val, entry_index); | 1836 | mac_key.low.val, entry_index); |
| 1842 | 1837 | ||
| 1843 | tcam_data.tbl_tcam_data_high = cpu_to_le32(mac_key.high.val); | 1838 | tcam_data.tbl_tcam_data_high = mac_key.high.val; |
| 1844 | tcam_data.tbl_tcam_data_low = cpu_to_le32(mac_key.low.val); | 1839 | tcam_data.tbl_tcam_data_low = mac_key.low.val; |
| 1845 | 1840 | ||
| 1846 | /* config mc entry with mask */ | 1841 | /* config mc entry with mask */ |
| 1847 | hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index, &tcam_data, | 1842 | hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index, &tcam_data, |
| @@ -1956,9 +1951,6 @@ int hns_dsaf_del_mac_mc_port(struct dsaf_device *dsaf_dev, | |||
| 1956 | /* config key mask */ | 1951 | /* config key mask */ |
| 1957 | hns_dsaf_set_mac_key(dsaf_dev, &mask_key, 0x00, 0xff, mc_mask); | 1952 | hns_dsaf_set_mac_key(dsaf_dev, &mask_key, 0x00, 0xff, mc_mask); |
| 1958 | 1953 | ||
| 1959 | mask_key.high.val = le32_to_cpu(mask_key.high.val); | ||
| 1960 | mask_key.low.val = le32_to_cpu(mask_key.low.val); | ||
| 1961 | |||
| 1962 | pmask_key = (struct dsaf_tbl_tcam_data *)(&mask_key); | 1954 | pmask_key = (struct dsaf_tbl_tcam_data *)(&mask_key); |
| 1963 | } | 1955 | } |
| 1964 | 1956 | ||
| @@ -2012,8 +2004,8 @@ int hns_dsaf_del_mac_mc_port(struct dsaf_device *dsaf_dev, | |||
| 2012 | soft_mac_entry += entry_index; | 2004 | soft_mac_entry += entry_index; |
| 2013 | soft_mac_entry->index = DSAF_INVALID_ENTRY_IDX; | 2005 | soft_mac_entry->index = DSAF_INVALID_ENTRY_IDX; |
| 2014 | } else { /* not zero, just del port, update */ | 2006 | } else { /* not zero, just del port, update */ |
| 2015 | tcam_data.tbl_tcam_data_high = cpu_to_le32(mac_key.high.val); | 2007 | tcam_data.tbl_tcam_data_high = mac_key.high.val; |
| 2016 | tcam_data.tbl_tcam_data_low = cpu_to_le32(mac_key.low.val); | 2008 | tcam_data.tbl_tcam_data_low = mac_key.low.val; |
| 2017 | 2009 | ||
| 2018 | hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index, | 2010 | hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index, |
| 2019 | &tcam_data, | 2011 | &tcam_data, |
| @@ -2750,6 +2742,17 @@ int hns_dsaf_get_regs_count(void) | |||
| 2750 | return DSAF_DUMP_REGS_NUM; | 2742 | return DSAF_DUMP_REGS_NUM; |
| 2751 | } | 2743 | } |
| 2752 | 2744 | ||
| 2745 | static int hns_dsaf_get_port_id(u8 port) | ||
| 2746 | { | ||
| 2747 | if (port < DSAF_SERVICE_NW_NUM) | ||
| 2748 | return port; | ||
| 2749 | |||
| 2750 | if (port >= DSAF_BASE_INNER_PORT_NUM) | ||
| 2751 | return port - DSAF_BASE_INNER_PORT_NUM + DSAF_SERVICE_NW_NUM; | ||
| 2752 | |||
| 2753 | return -EINVAL; | ||
| 2754 | } | ||
| 2755 | |||
| 2753 | static void set_promisc_tcam_enable(struct dsaf_device *dsaf_dev, u32 port) | 2756 | static void set_promisc_tcam_enable(struct dsaf_device *dsaf_dev, u32 port) |
| 2754 | { | 2757 | { |
| 2755 | struct dsaf_tbl_tcam_ucast_cfg tbl_tcam_ucast = {0, 1, 0, 0, 0x80}; | 2758 | struct dsaf_tbl_tcam_ucast_cfg tbl_tcam_ucast = {0, 1, 0, 0, 0x80}; |
| @@ -2815,23 +2818,33 @@ static void set_promisc_tcam_enable(struct dsaf_device *dsaf_dev, u32 port) | |||
| 2815 | memset(&temp_key, 0x0, sizeof(temp_key)); | 2818 | memset(&temp_key, 0x0, sizeof(temp_key)); |
| 2816 | mask_entry.addr[0] = 0x01; | 2819 | mask_entry.addr[0] = 0x01; |
| 2817 | hns_dsaf_set_mac_key(dsaf_dev, &mask_key, mask_entry.in_vlan_id, | 2820 | hns_dsaf_set_mac_key(dsaf_dev, &mask_key, mask_entry.in_vlan_id, |
| 2818 | port, mask_entry.addr); | 2821 | 0xf, mask_entry.addr); |
| 2819 | tbl_tcam_mcast.tbl_mcast_item_vld = 1; | 2822 | tbl_tcam_mcast.tbl_mcast_item_vld = 1; |
| 2820 | tbl_tcam_mcast.tbl_mcast_old_en = 0; | 2823 | tbl_tcam_mcast.tbl_mcast_old_en = 0; |
| 2821 | 2824 | ||
| 2822 | if (port < DSAF_SERVICE_NW_NUM) { | 2825 | /* set MAC port to handle multicast */ |
| 2823 | mskid = port; | 2826 | mskid = hns_dsaf_get_port_id(port); |
| 2824 | } else if (port >= DSAF_BASE_INNER_PORT_NUM) { | 2827 | if (mskid == -EINVAL) { |
| 2825 | mskid = port - DSAF_BASE_INNER_PORT_NUM + DSAF_SERVICE_NW_NUM; | ||
| 2826 | } else { | ||
| 2827 | dev_err(dsaf_dev->dev, "%s,pnum(%d)error,key(%#x:%#x)\n", | 2828 | dev_err(dsaf_dev->dev, "%s,pnum(%d)error,key(%#x:%#x)\n", |
| 2828 | dsaf_dev->ae_dev.name, port, | 2829 | dsaf_dev->ae_dev.name, port, |
| 2829 | mask_key.high.val, mask_key.low.val); | 2830 | mask_key.high.val, mask_key.low.val); |
| 2830 | return; | 2831 | return; |
| 2831 | } | 2832 | } |
| 2833 | dsaf_set_bit(tbl_tcam_mcast.tbl_mcast_port_msk[mskid / 32], | ||
| 2834 | mskid % 32, 1); | ||
| 2832 | 2835 | ||
| 2836 | /* set pool bit map to handle multicast */ | ||
| 2837 | mskid = hns_dsaf_get_port_id(port_num); | ||
| 2838 | if (mskid == -EINVAL) { | ||
| 2839 | dev_err(dsaf_dev->dev, | ||
| 2840 | "%s, pool bit map pnum(%d)error,key(%#x:%#x)\n", | ||
| 2841 | dsaf_dev->ae_dev.name, port_num, | ||
| 2842 | mask_key.high.val, mask_key.low.val); | ||
| 2843 | return; | ||
| 2844 | } | ||
| 2833 | dsaf_set_bit(tbl_tcam_mcast.tbl_mcast_port_msk[mskid / 32], | 2845 | dsaf_set_bit(tbl_tcam_mcast.tbl_mcast_port_msk[mskid / 32], |
| 2834 | mskid % 32, 1); | 2846 | mskid % 32, 1); |
| 2847 | |||
| 2835 | memcpy(&temp_key, &mask_key, sizeof(mask_key)); | 2848 | memcpy(&temp_key, &mask_key, sizeof(mask_key)); |
| 2836 | hns_dsaf_tcam_mc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_mc, | 2849 | hns_dsaf_tcam_mc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_mc, |
| 2837 | (struct dsaf_tbl_tcam_data *)(&mask_key), | 2850 | (struct dsaf_tbl_tcam_data *)(&mask_key), |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h index 0e1cd99831a6..76cc8887e1a8 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h | |||
| @@ -467,4 +467,6 @@ int hns_dsaf_clr_mac_mc_port(struct dsaf_device *dsaf_dev, | |||
| 467 | u8 mac_id, u8 port_num); | 467 | u8 mac_id, u8 port_num); |
| 468 | int hns_dsaf_wait_pkt_clean(struct dsaf_device *dsaf_dev, int port); | 468 | int hns_dsaf_wait_pkt_clean(struct dsaf_device *dsaf_dev, int port); |
| 469 | 469 | ||
| 470 | int hns_dsaf_roce_reset(struct fwnode_handle *dsaf_fwnode, bool dereset); | ||
| 471 | |||
| 470 | #endif /* __HNS_DSAF_MAIN_H__ */ | 472 | #endif /* __HNS_DSAF_MAIN_H__ */ |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c index 16294cd3c954..19b94879691f 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | |||
| @@ -670,7 +670,7 @@ static int hns_mac_config_sds_loopback(struct hns_mac_cb *mac_cb, bool en) | |||
| 670 | dsaf_set_field(origin, 1ull << 10, 10, en); | 670 | dsaf_set_field(origin, 1ull << 10, 10, en); |
| 671 | dsaf_write_syscon(mac_cb->serdes_ctrl, reg_offset, origin); | 671 | dsaf_write_syscon(mac_cb->serdes_ctrl, reg_offset, origin); |
| 672 | } else { | 672 | } else { |
| 673 | u8 *base_addr = (u8 *)mac_cb->serdes_vaddr + | 673 | u8 __iomem *base_addr = mac_cb->serdes_vaddr + |
| 674 | (mac_cb->mac_id <= 3 ? 0x00280000 : 0x00200000); | 674 | (mac_cb->mac_id <= 3 ? 0x00280000 : 0x00200000); |
| 675 | dsaf_set_reg_field(base_addr, reg_offset, 1ull << 10, 10, en); | 675 | dsaf_set_reg_field(base_addr, reg_offset, 1ull << 10, 10, en); |
| 676 | } | 676 | } |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c index 3d07c8a7639d..17c019106e6e 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | |||
| @@ -61,7 +61,7 @@ void hns_ppe_set_indir_table(struct hns_ppe_cb *ppe_cb, | |||
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static void __iomem * | 64 | static u8 __iomem * |
| 65 | hns_ppe_common_get_ioaddr(struct ppe_common_cb *ppe_common) | 65 | hns_ppe_common_get_ioaddr(struct ppe_common_cb *ppe_common) |
| 66 | { | 66 | { |
| 67 | return ppe_common->dsaf_dev->ppe_base + PPE_COMMON_REG_OFFSET; | 67 | return ppe_common->dsaf_dev->ppe_base + PPE_COMMON_REG_OFFSET; |
| @@ -111,8 +111,8 @@ hns_ppe_common_free_cfg(struct dsaf_device *dsaf_dev, u32 comm_index) | |||
| 111 | dsaf_dev->ppe_common[comm_index] = NULL; | 111 | dsaf_dev->ppe_common[comm_index] = NULL; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | static void __iomem *hns_ppe_get_iobase(struct ppe_common_cb *ppe_common, | 114 | static u8 __iomem *hns_ppe_get_iobase(struct ppe_common_cb *ppe_common, |
| 115 | int ppe_idx) | 115 | int ppe_idx) |
| 116 | { | 116 | { |
| 117 | return ppe_common->dsaf_dev->ppe_base + ppe_idx * PPE_REG_OFFSET; | 117 | return ppe_common->dsaf_dev->ppe_base + ppe_idx * PPE_REG_OFFSET; |
| 118 | } | 118 | } |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h index f670e63a5a01..110c6e8222c7 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h | |||
| @@ -80,7 +80,7 @@ struct hns_ppe_cb { | |||
| 80 | struct hns_ppe_hw_stats hw_stats; | 80 | struct hns_ppe_hw_stats hw_stats; |
| 81 | 81 | ||
| 82 | u8 index; /* index in a ppe common device */ | 82 | u8 index; /* index in a ppe common device */ |
| 83 | void __iomem *io_base; | 83 | u8 __iomem *io_base; |
| 84 | int virq; | 84 | int virq; |
| 85 | u32 rss_indir_table[HNS_PPEV2_RSS_IND_TBL_SIZE]; /*shadow indir tab */ | 85 | u32 rss_indir_table[HNS_PPEV2_RSS_IND_TBL_SIZE]; /*shadow indir tab */ |
| 86 | u32 rss_key[HNS_PPEV2_RSS_KEY_NUM]; /* rss hash key */ | 86 | u32 rss_key[HNS_PPEV2_RSS_KEY_NUM]; /* rss hash key */ |
| @@ -89,7 +89,7 @@ struct hns_ppe_cb { | |||
| 89 | struct ppe_common_cb { | 89 | struct ppe_common_cb { |
| 90 | struct device *dev; | 90 | struct device *dev; |
| 91 | struct dsaf_device *dsaf_dev; | 91 | struct dsaf_device *dsaf_dev; |
| 92 | void __iomem *io_base; | 92 | u8 __iomem *io_base; |
| 93 | 93 | ||
| 94 | enum ppe_common_mode ppe_mode; | 94 | enum ppe_common_mode ppe_mode; |
| 95 | 95 | ||
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c index 6bf346c11b25..ac3518ca4d7b 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | |||
| @@ -458,7 +458,7 @@ static void hns_rcb_ring_get_cfg(struct hnae_queue *q, int ring_type) | |||
| 458 | mdnum_ppkt = HNS_RCB_RING_MAX_BD_PER_PKT; | 458 | mdnum_ppkt = HNS_RCB_RING_MAX_BD_PER_PKT; |
| 459 | } else { | 459 | } else { |
| 460 | ring = &q->tx_ring; | 460 | ring = &q->tx_ring; |
| 461 | ring->io_base = (u8 __iomem *)ring_pair_cb->q.io_base + | 461 | ring->io_base = ring_pair_cb->q.io_base + |
| 462 | HNS_RCB_TX_REG_OFFSET; | 462 | HNS_RCB_TX_REG_OFFSET; |
| 463 | irq_idx = HNS_RCB_IRQ_IDX_TX; | 463 | irq_idx = HNS_RCB_IRQ_IDX_TX; |
| 464 | mdnum_ppkt = is_ver1 ? HNS_RCB_RING_MAX_TXBD_PER_PKT : | 464 | mdnum_ppkt = is_ver1 ? HNS_RCB_RING_MAX_TXBD_PER_PKT : |
| @@ -764,7 +764,7 @@ static int hns_rcb_get_ring_num(struct dsaf_device *dsaf_dev) | |||
| 764 | } | 764 | } |
| 765 | } | 765 | } |
| 766 | 766 | ||
| 767 | static void __iomem *hns_rcb_common_get_vaddr(struct rcb_common_cb *rcb_common) | 767 | static u8 __iomem *hns_rcb_common_get_vaddr(struct rcb_common_cb *rcb_common) |
| 768 | { | 768 | { |
| 769 | struct dsaf_device *dsaf_dev = rcb_common->dsaf_dev; | 769 | struct dsaf_device *dsaf_dev = rcb_common->dsaf_dev; |
| 770 | 770 | ||
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h index b9733b0b8482..b9e7f11f0896 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h | |||
| @@ -1018,7 +1018,7 @@ | |||
| 1018 | #define XGMAC_PAUSE_CTL_RSP_MODE_B 2 | 1018 | #define XGMAC_PAUSE_CTL_RSP_MODE_B 2 |
| 1019 | #define XGMAC_PAUSE_CTL_TX_XOFF_B 3 | 1019 | #define XGMAC_PAUSE_CTL_TX_XOFF_B 3 |
| 1020 | 1020 | ||
| 1021 | static inline void dsaf_write_reg(void __iomem *base, u32 reg, u32 value) | 1021 | static inline void dsaf_write_reg(u8 __iomem *base, u32 reg, u32 value) |
| 1022 | { | 1022 | { |
| 1023 | writel(value, base + reg); | 1023 | writel(value, base + reg); |
| 1024 | } | 1024 | } |
| @@ -1053,7 +1053,7 @@ static inline int dsaf_read_syscon(struct regmap *base, u32 reg, u32 *val) | |||
| 1053 | #define dsaf_set_bit(origin, shift, val) \ | 1053 | #define dsaf_set_bit(origin, shift, val) \ |
| 1054 | dsaf_set_field((origin), (1ull << (shift)), (shift), (val)) | 1054 | dsaf_set_field((origin), (1ull << (shift)), (shift), (val)) |
| 1055 | 1055 | ||
| 1056 | static inline void dsaf_set_reg_field(void __iomem *base, u32 reg, u32 mask, | 1056 | static inline void dsaf_set_reg_field(u8 __iomem *base, u32 reg, u32 mask, |
| 1057 | u32 shift, u32 val) | 1057 | u32 shift, u32 val) |
| 1058 | { | 1058 | { |
| 1059 | u32 origin = dsaf_read_reg(base, reg); | 1059 | u32 origin = dsaf_read_reg(base, reg); |
| @@ -1073,7 +1073,7 @@ static inline void dsaf_set_reg_field(void __iomem *base, u32 reg, u32 mask, | |||
| 1073 | #define dsaf_get_bit(origin, shift) \ | 1073 | #define dsaf_get_bit(origin, shift) \ |
| 1074 | dsaf_get_field((origin), (1ull << (shift)), (shift)) | 1074 | dsaf_get_field((origin), (1ull << (shift)), (shift)) |
| 1075 | 1075 | ||
| 1076 | static inline u32 dsaf_get_reg_field(void __iomem *base, u32 reg, u32 mask, | 1076 | static inline u32 dsaf_get_reg_field(u8 __iomem *base, u32 reg, u32 mask, |
| 1077 | u32 shift) | 1077 | u32 shift) |
| 1078 | { | 1078 | { |
| 1079 | u32 origin; | 1079 | u32 origin; |
| @@ -1089,11 +1089,11 @@ static inline u32 dsaf_get_reg_field(void __iomem *base, u32 reg, u32 mask, | |||
| 1089 | dsaf_get_reg_field((dev)->io_base, (reg), (1ull << (bit)), (bit)) | 1089 | dsaf_get_reg_field((dev)->io_base, (reg), (1ull << (bit)), (bit)) |
| 1090 | 1090 | ||
| 1091 | #define dsaf_write_b(addr, data)\ | 1091 | #define dsaf_write_b(addr, data)\ |
| 1092 | writeb((data), (__iomem unsigned char *)(addr)) | 1092 | writeb((data), (__iomem u8 *)(addr)) |
| 1093 | #define dsaf_read_b(addr)\ | 1093 | #define dsaf_read_b(addr)\ |
| 1094 | readb((__iomem unsigned char *)(addr)) | 1094 | readb((__iomem u8 *)(addr)) |
| 1095 | 1095 | ||
| 1096 | #define hns_mac_reg_read64(drv, offset) \ | 1096 | #define hns_mac_reg_read64(drv, offset) \ |
| 1097 | readq((__iomem void *)(((u8 *)(drv)->io_base + 0xc00 + (offset)))) | 1097 | readq((__iomem void *)(((drv)->io_base + 0xc00 + (offset)))) |
| 1098 | 1098 | ||
| 1099 | #endif /* _DSAF_REG_H */ | 1099 | #endif /* _DSAF_REG_H */ |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c index ba4316910dea..a60f207768fc 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c | |||
| @@ -129,7 +129,7 @@ static void hns_xgmac_lf_rf_control_init(struct mac_driver *mac_drv) | |||
| 129 | dsaf_set_bit(val, XGMAC_UNIDIR_EN_B, 0); | 129 | dsaf_set_bit(val, XGMAC_UNIDIR_EN_B, 0); |
| 130 | dsaf_set_bit(val, XGMAC_RF_TX_EN_B, 1); | 130 | dsaf_set_bit(val, XGMAC_RF_TX_EN_B, 1); |
| 131 | dsaf_set_field(val, XGMAC_LF_RF_INSERT_M, XGMAC_LF_RF_INSERT_S, 0); | 131 | dsaf_set_field(val, XGMAC_LF_RF_INSERT_M, XGMAC_LF_RF_INSERT_S, 0); |
| 132 | dsaf_write_reg(mac_drv, XGMAC_MAC_TX_LF_RF_CONTROL_REG, val); | 132 | dsaf_write_dev(mac_drv, XGMAC_MAC_TX_LF_RF_CONTROL_REG, val); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /** | 135 | /** |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 60e7d7ae3787..4cd86ba1f050 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c | |||
| @@ -29,9 +29,6 @@ | |||
| 29 | 29 | ||
| 30 | #define SERVICE_TIMER_HZ (1 * HZ) | 30 | #define SERVICE_TIMER_HZ (1 * HZ) |
| 31 | 31 | ||
| 32 | #define NIC_TX_CLEAN_MAX_NUM 256 | ||
| 33 | #define NIC_RX_CLEAN_MAX_NUM 64 | ||
| 34 | |||
| 35 | #define RCB_IRQ_NOT_INITED 0 | 32 | #define RCB_IRQ_NOT_INITED 0 |
| 36 | #define RCB_IRQ_INITED 1 | 33 | #define RCB_IRQ_INITED 1 |
| 37 | #define HNS_BUFFER_SIZE_2048 2048 | 34 | #define HNS_BUFFER_SIZE_2048 2048 |
| @@ -376,8 +373,6 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev, | |||
| 376 | wmb(); /* commit all data before submit */ | 373 | wmb(); /* commit all data before submit */ |
| 377 | assert(skb->queue_mapping < priv->ae_handle->q_num); | 374 | assert(skb->queue_mapping < priv->ae_handle->q_num); |
| 378 | hnae_queue_xmit(priv->ae_handle->qs[skb->queue_mapping], buf_num); | 375 | hnae_queue_xmit(priv->ae_handle->qs[skb->queue_mapping], buf_num); |
| 379 | ring->stats.tx_pkts++; | ||
| 380 | ring->stats.tx_bytes += skb->len; | ||
| 381 | 376 | ||
| 382 | return NETDEV_TX_OK; | 377 | return NETDEV_TX_OK; |
| 383 | 378 | ||
| @@ -999,6 +994,9 @@ static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data, | |||
| 999 | /* issue prefetch for next Tx descriptor */ | 994 | /* issue prefetch for next Tx descriptor */ |
| 1000 | prefetch(&ring->desc_cb[ring->next_to_clean]); | 995 | prefetch(&ring->desc_cb[ring->next_to_clean]); |
| 1001 | } | 996 | } |
| 997 | /* update tx ring statistics. */ | ||
| 998 | ring->stats.tx_pkts += pkts; | ||
| 999 | ring->stats.tx_bytes += bytes; | ||
| 1002 | 1000 | ||
| 1003 | NETIF_TX_UNLOCK(ring); | 1001 | NETIF_TX_UNLOCK(ring); |
| 1004 | 1002 | ||
| @@ -2152,7 +2150,7 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv) | |||
| 2152 | hns_nic_tx_fini_pro_v2; | 2150 | hns_nic_tx_fini_pro_v2; |
| 2153 | 2151 | ||
| 2154 | netif_napi_add(priv->netdev, &rd->napi, | 2152 | netif_napi_add(priv->netdev, &rd->napi, |
| 2155 | hns_nic_common_poll, NIC_TX_CLEAN_MAX_NUM); | 2153 | hns_nic_common_poll, NAPI_POLL_WEIGHT); |
| 2156 | rd->ring->irq_init_flag = RCB_IRQ_NOT_INITED; | 2154 | rd->ring->irq_init_flag = RCB_IRQ_NOT_INITED; |
| 2157 | } | 2155 | } |
| 2158 | for (i = h->q_num; i < h->q_num * 2; i++) { | 2156 | for (i = h->q_num; i < h->q_num * 2; i++) { |
| @@ -2165,7 +2163,7 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv) | |||
| 2165 | hns_nic_rx_fini_pro_v2; | 2163 | hns_nic_rx_fini_pro_v2; |
| 2166 | 2164 | ||
| 2167 | netif_napi_add(priv->netdev, &rd->napi, | 2165 | netif_napi_add(priv->netdev, &rd->napi, |
| 2168 | hns_nic_common_poll, NIC_RX_CLEAN_MAX_NUM); | 2166 | hns_nic_common_poll, NAPI_POLL_WEIGHT); |
| 2169 | rd->ring->irq_init_flag = RCB_IRQ_NOT_INITED; | 2167 | rd->ring->irq_init_flag = RCB_IRQ_NOT_INITED; |
| 2170 | } | 2168 | } |
| 2171 | 2169 | ||
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 1c1f17ec6be2..162cb9afa0e7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include "hns3_enet.h" | 22 | #include "hns3_enet.h" |
| 23 | 23 | ||
| 24 | #define hns3_set_field(origin, shift, val) ((origin) |= ((val) << (shift))) | 24 | #define hns3_set_field(origin, shift, val) ((origin) |= ((val) << (shift))) |
| 25 | #define hns3_tx_bd_count(S) DIV_ROUND_UP(S, HNS3_MAX_BD_SIZE) | ||
| 25 | 26 | ||
| 26 | static void hns3_clear_all_ring(struct hnae3_handle *h); | 27 | static void hns3_clear_all_ring(struct hnae3_handle *h); |
| 27 | static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h); | 28 | static void hns3_force_clear_all_rx_ring(struct hnae3_handle *h); |
| @@ -1079,7 +1080,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, | |||
| 1079 | 1080 | ||
| 1080 | desc_cb->length = size; | 1081 | desc_cb->length = size; |
| 1081 | 1082 | ||
| 1082 | frag_buf_num = (size + HNS3_MAX_BD_SIZE - 1) >> HNS3_MAX_BD_SIZE_OFFSET; | 1083 | frag_buf_num = hns3_tx_bd_count(size); |
| 1083 | sizeoflast = size & HNS3_TX_LAST_SIZE_M; | 1084 | sizeoflast = size & HNS3_TX_LAST_SIZE_M; |
| 1084 | sizeoflast = sizeoflast ? sizeoflast : HNS3_MAX_BD_SIZE; | 1085 | sizeoflast = sizeoflast ? sizeoflast : HNS3_MAX_BD_SIZE; |
| 1085 | 1086 | ||
| @@ -1124,14 +1125,13 @@ static int hns3_nic_maybe_stop_tso(struct sk_buff **out_skb, int *bnum, | |||
| 1124 | int i; | 1125 | int i; |
| 1125 | 1126 | ||
| 1126 | size = skb_headlen(skb); | 1127 | size = skb_headlen(skb); |
| 1127 | buf_num = (size + HNS3_MAX_BD_SIZE - 1) >> HNS3_MAX_BD_SIZE_OFFSET; | 1128 | buf_num = hns3_tx_bd_count(size); |
| 1128 | 1129 | ||
| 1129 | frag_num = skb_shinfo(skb)->nr_frags; | 1130 | frag_num = skb_shinfo(skb)->nr_frags; |
| 1130 | for (i = 0; i < frag_num; i++) { | 1131 | for (i = 0; i < frag_num; i++) { |
| 1131 | frag = &skb_shinfo(skb)->frags[i]; | 1132 | frag = &skb_shinfo(skb)->frags[i]; |
| 1132 | size = skb_frag_size(frag); | 1133 | size = skb_frag_size(frag); |
| 1133 | bdnum_for_frag = (size + HNS3_MAX_BD_SIZE - 1) >> | 1134 | bdnum_for_frag = hns3_tx_bd_count(size); |
| 1134 | HNS3_MAX_BD_SIZE_OFFSET; | ||
| 1135 | if (unlikely(bdnum_for_frag > HNS3_MAX_BD_PER_FRAG)) | 1135 | if (unlikely(bdnum_for_frag > HNS3_MAX_BD_PER_FRAG)) |
| 1136 | return -ENOMEM; | 1136 | return -ENOMEM; |
| 1137 | 1137 | ||
| @@ -1139,8 +1139,7 @@ static int hns3_nic_maybe_stop_tso(struct sk_buff **out_skb, int *bnum, | |||
| 1139 | } | 1139 | } |
| 1140 | 1140 | ||
| 1141 | if (unlikely(buf_num > HNS3_MAX_BD_PER_FRAG)) { | 1141 | if (unlikely(buf_num > HNS3_MAX_BD_PER_FRAG)) { |
| 1142 | buf_num = (skb->len + HNS3_MAX_BD_SIZE - 1) >> | 1142 | buf_num = hns3_tx_bd_count(skb->len); |
| 1143 | HNS3_MAX_BD_SIZE_OFFSET; | ||
| 1144 | if (ring_space(ring) < buf_num) | 1143 | if (ring_space(ring) < buf_num) |
| 1145 | return -EBUSY; | 1144 | return -EBUSY; |
| 1146 | /* manual split the send packet */ | 1145 | /* manual split the send packet */ |
| @@ -1169,7 +1168,7 @@ static int hns3_nic_maybe_stop_tx(struct sk_buff **out_skb, int *bnum, | |||
| 1169 | buf_num = skb_shinfo(skb)->nr_frags + 1; | 1168 | buf_num = skb_shinfo(skb)->nr_frags + 1; |
| 1170 | 1169 | ||
| 1171 | if (unlikely(buf_num > HNS3_MAX_BD_PER_FRAG)) { | 1170 | if (unlikely(buf_num > HNS3_MAX_BD_PER_FRAG)) { |
| 1172 | buf_num = (skb->len + HNS3_MAX_BD_SIZE - 1) / HNS3_MAX_BD_SIZE; | 1171 | buf_num = hns3_tx_bd_count(skb->len); |
| 1173 | if (ring_space(ring) < buf_num) | 1172 | if (ring_space(ring) < buf_num) |
| 1174 | return -EBUSY; | 1173 | return -EBUSY; |
| 1175 | /* manual split the send packet */ | 1174 | /* manual split the send packet */ |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 1db0bd41d209..75669cd0c311 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | |||
| @@ -193,7 +193,6 @@ enum hns3_nic_state { | |||
| 193 | #define HNS3_VECTOR_INITED 1 | 193 | #define HNS3_VECTOR_INITED 1 |
| 194 | 194 | ||
| 195 | #define HNS3_MAX_BD_SIZE 65535 | 195 | #define HNS3_MAX_BD_SIZE 65535 |
| 196 | #define HNS3_MAX_BD_SIZE_OFFSET 16 | ||
| 197 | #define HNS3_MAX_BD_PER_FRAG 8 | 196 | #define HNS3_MAX_BD_PER_FRAG 8 |
| 198 | #define HNS3_MAX_BD_PER_PKT MAX_SKB_FRAGS | 197 | #define HNS3_MAX_BD_PER_PKT MAX_SKB_FRAGS |
| 199 | 198 | ||
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile b/drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile index fffe8c1c45d3..0fb61d440d3b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | # Makefile for the HISILICON network device drivers. | 3 | # Makefile for the HISILICON network device drivers. |
| 4 | # | 4 | # |
| 5 | 5 | ||
| 6 | ccflags-y := -Idrivers/net/ethernet/hisilicon/hns3 | 6 | ccflags-y := -I $(srctree)/drivers/net/ethernet/hisilicon/hns3 |
| 7 | 7 | ||
| 8 | obj-$(CONFIG_HNS3_HCLGE) += hclge.o | 8 | obj-$(CONFIG_HNS3_HCLGE) += hclge.o |
| 9 | hclge-objs = hclge_main.o hclge_cmd.o hclge_mdio.o hclge_tm.o hclge_mbx.o hclge_err.o hclge_debugfs.o | 9 | hclge-objs = hclge_main.o hclge_cmd.o hclge_mdio.o hclge_tm.o hclge_mbx.o hclge_err.o hclge_debugfs.o |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/Makefile b/drivers/net/ethernet/hisilicon/hns3/hns3vf/Makefile index fb93bbd35845..6193f8fa7cf3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/Makefile +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/Makefile | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | # Makefile for the HISILICON network device drivers. | 3 | # Makefile for the HISILICON network device drivers. |
| 4 | # | 4 | # |
| 5 | 5 | ||
| 6 | ccflags-y := -Idrivers/net/ethernet/hisilicon/hns3 | 6 | ccflags-y := -I $(srctree)/drivers/net/ethernet/hisilicon/hns3 |
| 7 | 7 | ||
| 8 | obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o | 8 | obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o |
| 9 | hclgevf-objs = hclgevf_main.o hclgevf_cmd.o hclgevf_mbx.o \ No newline at end of file | 9 | hclgevf-objs = hclgevf_main.o hclgevf_cmd.o hclgevf_mbx.o \ No newline at end of file |
diff --git a/drivers/net/ethernet/hisilicon/hns_mdio.c b/drivers/net/ethernet/hisilicon/hns_mdio.c index baf5cc251f32..8b8a7d00e8e0 100644 --- a/drivers/net/ethernet/hisilicon/hns_mdio.c +++ b/drivers/net/ethernet/hisilicon/hns_mdio.c | |||
| @@ -39,7 +39,7 @@ struct hns_mdio_sc_reg { | |||
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | struct hns_mdio_device { | 41 | struct hns_mdio_device { |
| 42 | void *vbase; /* mdio reg base address */ | 42 | u8 __iomem *vbase; /* mdio reg base address */ |
| 43 | struct regmap *subctrl_vbase; | 43 | struct regmap *subctrl_vbase; |
| 44 | struct hns_mdio_sc_reg sc_reg; | 44 | struct hns_mdio_sc_reg sc_reg; |
| 45 | }; | 45 | }; |
| @@ -96,21 +96,17 @@ enum mdio_c45_op_seq { | |||
| 96 | #define MDIO_SC_CLK_ST 0x531C | 96 | #define MDIO_SC_CLK_ST 0x531C |
| 97 | #define MDIO_SC_RESET_ST 0x5A1C | 97 | #define MDIO_SC_RESET_ST 0x5A1C |
| 98 | 98 | ||
| 99 | static void mdio_write_reg(void *base, u32 reg, u32 value) | 99 | static void mdio_write_reg(u8 __iomem *base, u32 reg, u32 value) |
| 100 | { | 100 | { |
| 101 | u8 __iomem *reg_addr = (u8 __iomem *)base; | 101 | writel_relaxed(value, base + reg); |
| 102 | |||
| 103 | writel_relaxed(value, reg_addr + reg); | ||
| 104 | } | 102 | } |
| 105 | 103 | ||
| 106 | #define MDIO_WRITE_REG(a, reg, value) \ | 104 | #define MDIO_WRITE_REG(a, reg, value) \ |
| 107 | mdio_write_reg((a)->vbase, (reg), (value)) | 105 | mdio_write_reg((a)->vbase, (reg), (value)) |
| 108 | 106 | ||
| 109 | static u32 mdio_read_reg(void *base, u32 reg) | 107 | static u32 mdio_read_reg(u8 __iomem *base, u32 reg) |
| 110 | { | 108 | { |
| 111 | u8 __iomem *reg_addr = (u8 __iomem *)base; | 109 | return readl_relaxed(base + reg); |
| 112 | |||
| 113 | return readl_relaxed(reg_addr + reg); | ||
| 114 | } | 110 | } |
| 115 | 111 | ||
| 116 | #define mdio_set_field(origin, mask, shift, val) \ | 112 | #define mdio_set_field(origin, mask, shift, val) \ |
| @@ -121,7 +117,7 @@ static u32 mdio_read_reg(void *base, u32 reg) | |||
| 121 | 117 | ||
| 122 | #define mdio_get_field(origin, mask, shift) (((origin) >> (shift)) & (mask)) | 118 | #define mdio_get_field(origin, mask, shift) (((origin) >> (shift)) & (mask)) |
| 123 | 119 | ||
| 124 | static void mdio_set_reg_field(void *base, u32 reg, u32 mask, u32 shift, | 120 | static void mdio_set_reg_field(u8 __iomem *base, u32 reg, u32 mask, u32 shift, |
| 125 | u32 val) | 121 | u32 val) |
| 126 | { | 122 | { |
| 127 | u32 origin = mdio_read_reg(base, reg); | 123 | u32 origin = mdio_read_reg(base, reg); |
| @@ -133,7 +129,7 @@ static void mdio_set_reg_field(void *base, u32 reg, u32 mask, u32 shift, | |||
| 133 | #define MDIO_SET_REG_FIELD(dev, reg, mask, shift, val) \ | 129 | #define MDIO_SET_REG_FIELD(dev, reg, mask, shift, val) \ |
| 134 | mdio_set_reg_field((dev)->vbase, (reg), (mask), (shift), (val)) | 130 | mdio_set_reg_field((dev)->vbase, (reg), (mask), (shift), (val)) |
| 135 | 131 | ||
| 136 | static u32 mdio_get_reg_field(void *base, u32 reg, u32 mask, u32 shift) | 132 | static u32 mdio_get_reg_field(u8 __iomem *base, u32 reg, u32 mask, u32 shift) |
| 137 | { | 133 | { |
| 138 | u32 origin; | 134 | u32 origin; |
| 139 | 135 | ||
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c index 3baabdc89726..90b62c1412c8 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_main.c +++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c | |||
| @@ -3160,6 +3160,7 @@ static ssize_t ehea_probe_port(struct device *dev, | |||
| 3160 | 3160 | ||
| 3161 | if (ehea_add_adapter_mr(adapter)) { | 3161 | if (ehea_add_adapter_mr(adapter)) { |
| 3162 | pr_err("creating MR failed\n"); | 3162 | pr_err("creating MR failed\n"); |
| 3163 | of_node_put(eth_dn); | ||
| 3163 | return -EIO; | 3164 | return -EIO; |
| 3164 | } | 3165 | } |
| 3165 | 3166 | ||
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index 5ecbb1adcf3b..51cfe95f3e24 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c | |||
| @@ -1885,6 +1885,7 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter, | |||
| 1885 | */ | 1885 | */ |
| 1886 | adapter->state = VNIC_PROBED; | 1886 | adapter->state = VNIC_PROBED; |
| 1887 | 1887 | ||
| 1888 | reinit_completion(&adapter->init_done); | ||
| 1888 | rc = init_crq_queue(adapter); | 1889 | rc = init_crq_queue(adapter); |
| 1889 | if (rc) { | 1890 | if (rc) { |
| 1890 | netdev_err(adapter->netdev, | 1891 | netdev_err(adapter->netdev, |
| @@ -4625,7 +4626,7 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter) | |||
| 4625 | old_num_rx_queues = adapter->req_rx_queues; | 4626 | old_num_rx_queues = adapter->req_rx_queues; |
| 4626 | old_num_tx_queues = adapter->req_tx_queues; | 4627 | old_num_tx_queues = adapter->req_tx_queues; |
| 4627 | 4628 | ||
| 4628 | init_completion(&adapter->init_done); | 4629 | reinit_completion(&adapter->init_done); |
| 4629 | adapter->init_done_rc = 0; | 4630 | adapter->init_done_rc = 0; |
| 4630 | ibmvnic_send_crq_init(adapter); | 4631 | ibmvnic_send_crq_init(adapter); |
| 4631 | if (!wait_for_completion_timeout(&adapter->init_done, timeout)) { | 4632 | if (!wait_for_completion_timeout(&adapter->init_done, timeout)) { |
| @@ -4680,7 +4681,6 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter) | |||
| 4680 | 4681 | ||
| 4681 | adapter->from_passive_init = false; | 4682 | adapter->from_passive_init = false; |
| 4682 | 4683 | ||
| 4683 | init_completion(&adapter->init_done); | ||
| 4684 | adapter->init_done_rc = 0; | 4684 | adapter->init_done_rc = 0; |
| 4685 | ibmvnic_send_crq_init(adapter); | 4685 | ibmvnic_send_crq_init(adapter); |
| 4686 | if (!wait_for_completion_timeout(&adapter->init_done, timeout)) { | 4686 | if (!wait_for_completion_timeout(&adapter->init_done, timeout)) { |
| @@ -4759,6 +4759,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) | |||
| 4759 | INIT_WORK(&adapter->ibmvnic_reset, __ibmvnic_reset); | 4759 | INIT_WORK(&adapter->ibmvnic_reset, __ibmvnic_reset); |
| 4760 | INIT_LIST_HEAD(&adapter->rwi_list); | 4760 | INIT_LIST_HEAD(&adapter->rwi_list); |
| 4761 | spin_lock_init(&adapter->rwi_lock); | 4761 | spin_lock_init(&adapter->rwi_lock); |
| 4762 | init_completion(&adapter->init_done); | ||
| 4762 | adapter->resetting = false; | 4763 | adapter->resetting = false; |
| 4763 | 4764 | ||
| 4764 | adapter->mac_change_pending = false; | 4765 | adapter->mac_change_pending = false; |
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c index 5a0419421511..ecef949f3baa 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c | |||
| @@ -41,6 +41,8 @@ static int __init fm10k_init_module(void) | |||
| 41 | /* create driver workqueue */ | 41 | /* create driver workqueue */ |
| 42 | fm10k_workqueue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 0, | 42 | fm10k_workqueue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 0, |
| 43 | fm10k_driver_name); | 43 | fm10k_driver_name); |
| 44 | if (!fm10k_workqueue) | ||
| 45 | return -ENOMEM; | ||
| 44 | 46 | ||
| 45 | fm10k_dbg_init(); | 47 | fm10k_dbg_init(); |
| 46 | 48 | ||
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index d684998ba2b0..d3cc3427caad 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h | |||
| @@ -790,6 +790,8 @@ struct i40e_vsi { | |||
| 790 | 790 | ||
| 791 | /* VSI specific handlers */ | 791 | /* VSI specific handlers */ |
| 792 | irqreturn_t (*irq_handler)(int irq, void *data); | 792 | irqreturn_t (*irq_handler)(int irq, void *data); |
| 793 | |||
| 794 | unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled qps */ | ||
| 793 | } ____cacheline_internodealigned_in_smp; | 795 | } ____cacheline_internodealigned_in_smp; |
| 794 | 796 | ||
| 795 | struct i40e_netdev_priv { | 797 | struct i40e_netdev_priv { |
| @@ -1096,20 +1098,6 @@ static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi) | |||
| 1096 | return !!vsi->xdp_prog; | 1098 | return !!vsi->xdp_prog; |
| 1097 | } | 1099 | } |
| 1098 | 1100 | ||
| 1099 | static inline struct xdp_umem *i40e_xsk_umem(struct i40e_ring *ring) | ||
| 1100 | { | ||
| 1101 | bool xdp_on = i40e_enabled_xdp_vsi(ring->vsi); | ||
| 1102 | int qid = ring->queue_index; | ||
| 1103 | |||
| 1104 | if (ring_is_xdp(ring)) | ||
| 1105 | qid -= ring->vsi->alloc_queue_pairs; | ||
| 1106 | |||
| 1107 | if (!xdp_on) | ||
| 1108 | return NULL; | ||
| 1109 | |||
| 1110 | return xdp_get_umem_from_qid(ring->vsi->netdev, qid); | ||
| 1111 | } | ||
| 1112 | |||
| 1113 | int i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch); | 1101 | int i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch); |
| 1114 | int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate); | 1102 | int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate); |
| 1115 | int i40e_add_del_cloud_filter(struct i40e_vsi *vsi, | 1103 | int i40e_add_del_cloud_filter(struct i40e_vsi *vsi, |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c index 4c885801fa26..7874d0ec7fb0 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c | |||
| @@ -2573,8 +2573,7 @@ static int i40e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) | |||
| 2573 | return -EOPNOTSUPP; | 2573 | return -EOPNOTSUPP; |
| 2574 | 2574 | ||
| 2575 | /* only magic packet is supported */ | 2575 | /* only magic packet is supported */ |
| 2576 | if (wol->wolopts && (wol->wolopts != WAKE_MAGIC) | 2576 | if (wol->wolopts & ~WAKE_MAGIC) |
| 2577 | | (wol->wolopts != WAKE_FILTER)) | ||
| 2578 | return -EOPNOTSUPP; | 2577 | return -EOPNOTSUPP; |
| 2579 | 2578 | ||
| 2580 | /* is this a new value? */ | 2579 | /* is this a new value? */ |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index da62218eb70a..b1c265012c8a 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c | |||
| @@ -3064,6 +3064,26 @@ static void i40e_config_xps_tx_ring(struct i40e_ring *ring) | |||
| 3064 | } | 3064 | } |
| 3065 | 3065 | ||
| 3066 | /** | 3066 | /** |
| 3067 | * i40e_xsk_umem - Retrieve the AF_XDP ZC if XDP and ZC is enabled | ||
| 3068 | * @ring: The Tx or Rx ring | ||
| 3069 | * | ||
| 3070 | * Returns the UMEM or NULL. | ||
| 3071 | **/ | ||
| 3072 | static struct xdp_umem *i40e_xsk_umem(struct i40e_ring *ring) | ||
| 3073 | { | ||
| 3074 | bool xdp_on = i40e_enabled_xdp_vsi(ring->vsi); | ||
| 3075 | int qid = ring->queue_index; | ||
| 3076 | |||
| 3077 | if (ring_is_xdp(ring)) | ||
| 3078 | qid -= ring->vsi->alloc_queue_pairs; | ||
| 3079 | |||
| 3080 | if (!xdp_on || !test_bit(qid, ring->vsi->af_xdp_zc_qps)) | ||
| 3081 | return NULL; | ||
| 3082 | |||
| 3083 | return xdp_get_umem_from_qid(ring->vsi->netdev, qid); | ||
| 3084 | } | ||
| 3085 | |||
| 3086 | /** | ||
| 3067 | * i40e_configure_tx_ring - Configure a transmit ring context and rest | 3087 | * i40e_configure_tx_ring - Configure a transmit ring context and rest |
| 3068 | * @ring: The Tx ring to configure | 3088 | * @ring: The Tx ring to configure |
| 3069 | * | 3089 | * |
| @@ -10064,6 +10084,12 @@ static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type) | |||
| 10064 | hash_init(vsi->mac_filter_hash); | 10084 | hash_init(vsi->mac_filter_hash); |
| 10065 | vsi->irqs_ready = false; | 10085 | vsi->irqs_ready = false; |
| 10066 | 10086 | ||
| 10087 | if (type == I40E_VSI_MAIN) { | ||
| 10088 | vsi->af_xdp_zc_qps = bitmap_zalloc(pf->num_lan_qps, GFP_KERNEL); | ||
| 10089 | if (!vsi->af_xdp_zc_qps) | ||
| 10090 | goto err_rings; | ||
| 10091 | } | ||
| 10092 | |||
| 10067 | ret = i40e_set_num_rings_in_vsi(vsi); | 10093 | ret = i40e_set_num_rings_in_vsi(vsi); |
| 10068 | if (ret) | 10094 | if (ret) |
| 10069 | goto err_rings; | 10095 | goto err_rings; |
| @@ -10082,6 +10108,7 @@ static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type) | |||
| 10082 | goto unlock_pf; | 10108 | goto unlock_pf; |
| 10083 | 10109 | ||
| 10084 | err_rings: | 10110 | err_rings: |
| 10111 | bitmap_free(vsi->af_xdp_zc_qps); | ||
| 10085 | pf->next_vsi = i - 1; | 10112 | pf->next_vsi = i - 1; |
| 10086 | kfree(vsi); | 10113 | kfree(vsi); |
| 10087 | unlock_pf: | 10114 | unlock_pf: |
| @@ -10162,6 +10189,7 @@ static int i40e_vsi_clear(struct i40e_vsi *vsi) | |||
| 10162 | i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); | 10189 | i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); |
| 10163 | i40e_put_lump(pf->irq_pile, vsi->base_vector, vsi->idx); | 10190 | i40e_put_lump(pf->irq_pile, vsi->base_vector, vsi->idx); |
| 10164 | 10191 | ||
| 10192 | bitmap_free(vsi->af_xdp_zc_qps); | ||
| 10165 | i40e_vsi_free_arrays(vsi, true); | 10193 | i40e_vsi_free_arrays(vsi, true); |
| 10166 | i40e_clear_rss_config_user(vsi); | 10194 | i40e_clear_rss_config_user(vsi); |
| 10167 | 10195 | ||
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c index 5fb4353c742b..31575c0bb884 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c | |||
| @@ -146,12 +146,13 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) | |||
| 146 | static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) | 146 | static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) |
| 147 | { | 147 | { |
| 148 | struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); | 148 | struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); |
| 149 | struct timespec64 now; | 149 | struct timespec64 now, then; |
| 150 | 150 | ||
| 151 | then = ns_to_timespec64(delta); | ||
| 151 | mutex_lock(&pf->tmreg_lock); | 152 | mutex_lock(&pf->tmreg_lock); |
| 152 | 153 | ||
| 153 | i40e_ptp_read(pf, &now, NULL); | 154 | i40e_ptp_read(pf, &now, NULL); |
| 154 | timespec64_add_ns(&now, delta); | 155 | now = timespec64_add(now, then); |
| 155 | i40e_ptp_write(pf, (const struct timespec64 *)&now); | 156 | i40e_ptp_write(pf, (const struct timespec64 *)&now); |
| 156 | 157 | ||
| 157 | mutex_unlock(&pf->tmreg_lock); | 158 | mutex_unlock(&pf->tmreg_lock); |
diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c index b5c182e688e3..1b17486543ac 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c | |||
| @@ -102,6 +102,8 @@ static int i40e_xsk_umem_enable(struct i40e_vsi *vsi, struct xdp_umem *umem, | |||
| 102 | if (err) | 102 | if (err) |
| 103 | return err; | 103 | return err; |
| 104 | 104 | ||
| 105 | set_bit(qid, vsi->af_xdp_zc_qps); | ||
| 106 | |||
| 105 | if_running = netif_running(vsi->netdev) && i40e_enabled_xdp_vsi(vsi); | 107 | if_running = netif_running(vsi->netdev) && i40e_enabled_xdp_vsi(vsi); |
| 106 | 108 | ||
| 107 | if (if_running) { | 109 | if (if_running) { |
| @@ -148,6 +150,7 @@ static int i40e_xsk_umem_disable(struct i40e_vsi *vsi, u16 qid) | |||
| 148 | return err; | 150 | return err; |
| 149 | } | 151 | } |
| 150 | 152 | ||
| 153 | clear_bit(qid, vsi->af_xdp_zc_qps); | ||
| 151 | i40e_xsk_umem_dma_unmap(vsi, umem); | 154 | i40e_xsk_umem_dma_unmap(vsi, umem); |
| 152 | 155 | ||
| 153 | if (if_running) { | 156 | if (if_running) { |
diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h index 01fcfc6f3415..d2e2c50ce257 100644 --- a/drivers/net/ethernet/intel/igb/e1000_defines.h +++ b/drivers/net/ethernet/intel/igb/e1000_defines.h | |||
| @@ -194,6 +194,8 @@ | |||
| 194 | /* enable link status from external LINK_0 and LINK_1 pins */ | 194 | /* enable link status from external LINK_0 and LINK_1 pins */ |
| 195 | #define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */ | 195 | #define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */ |
| 196 | #define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */ | 196 | #define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */ |
| 197 | #define E1000_CTRL_ADVD3WUC 0x00100000 /* D3 WUC */ | ||
| 198 | #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000 /* PHY PM enable */ | ||
| 197 | #define E1000_CTRL_SDP0_DIR 0x00400000 /* SDP0 Data direction */ | 199 | #define E1000_CTRL_SDP0_DIR 0x00400000 /* SDP0 Data direction */ |
| 198 | #define E1000_CTRL_SDP1_DIR 0x00800000 /* SDP1 Data direction */ | 200 | #define E1000_CTRL_SDP1_DIR 0x00800000 /* SDP1 Data direction */ |
| 199 | #define E1000_CTRL_RST 0x04000000 /* Global reset */ | 201 | #define E1000_CTRL_RST 0x04000000 /* Global reset */ |
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 69b230c53fed..3269d8e94744 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
| @@ -8740,9 +8740,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake, | |||
| 8740 | struct e1000_hw *hw = &adapter->hw; | 8740 | struct e1000_hw *hw = &adapter->hw; |
| 8741 | u32 ctrl, rctl, status; | 8741 | u32 ctrl, rctl, status; |
| 8742 | u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol; | 8742 | u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol; |
| 8743 | #ifdef CONFIG_PM | 8743 | bool wake; |
| 8744 | int retval = 0; | ||
| 8745 | #endif | ||
| 8746 | 8744 | ||
| 8747 | rtnl_lock(); | 8745 | rtnl_lock(); |
| 8748 | netif_device_detach(netdev); | 8746 | netif_device_detach(netdev); |
| @@ -8755,14 +8753,6 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake, | |||
| 8755 | igb_clear_interrupt_scheme(adapter); | 8753 | igb_clear_interrupt_scheme(adapter); |
| 8756 | rtnl_unlock(); | 8754 | rtnl_unlock(); |
| 8757 | 8755 | ||
| 8758 | #ifdef CONFIG_PM | ||
| 8759 | if (!runtime) { | ||
| 8760 | retval = pci_save_state(pdev); | ||
| 8761 | if (retval) | ||
| 8762 | return retval; | ||
| 8763 | } | ||
| 8764 | #endif | ||
| 8765 | |||
| 8766 | status = rd32(E1000_STATUS); | 8756 | status = rd32(E1000_STATUS); |
| 8767 | if (status & E1000_STATUS_LU) | 8757 | if (status & E1000_STATUS_LU) |
| 8768 | wufc &= ~E1000_WUFC_LNKC; | 8758 | wufc &= ~E1000_WUFC_LNKC; |
| @@ -8779,10 +8769,6 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake, | |||
| 8779 | } | 8769 | } |
| 8780 | 8770 | ||
| 8781 | ctrl = rd32(E1000_CTRL); | 8771 | ctrl = rd32(E1000_CTRL); |
| 8782 | /* advertise wake from D3Cold */ | ||
| 8783 | #define E1000_CTRL_ADVD3WUC 0x00100000 | ||
| 8784 | /* phy power management enable */ | ||
| 8785 | #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000 | ||
| 8786 | ctrl |= E1000_CTRL_ADVD3WUC; | 8772 | ctrl |= E1000_CTRL_ADVD3WUC; |
| 8787 | wr32(E1000_CTRL, ctrl); | 8773 | wr32(E1000_CTRL, ctrl); |
| 8788 | 8774 | ||
| @@ -8796,12 +8782,15 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake, | |||
| 8796 | wr32(E1000_WUFC, 0); | 8782 | wr32(E1000_WUFC, 0); |
| 8797 | } | 8783 | } |
| 8798 | 8784 | ||
| 8799 | *enable_wake = wufc || adapter->en_mng_pt; | 8785 | wake = wufc || adapter->en_mng_pt; |
| 8800 | if (!*enable_wake) | 8786 | if (!wake) |
| 8801 | igb_power_down_link(adapter); | 8787 | igb_power_down_link(adapter); |
| 8802 | else | 8788 | else |
| 8803 | igb_power_up_link(adapter); | 8789 | igb_power_up_link(adapter); |
| 8804 | 8790 | ||
| 8791 | if (enable_wake) | ||
| 8792 | *enable_wake = wake; | ||
| 8793 | |||
| 8805 | /* Release control of h/w to f/w. If f/w is AMT enabled, this | 8794 | /* Release control of h/w to f/w. If f/w is AMT enabled, this |
| 8806 | * would have already happened in close and is redundant. | 8795 | * would have already happened in close and is redundant. |
| 8807 | */ | 8796 | */ |
| @@ -8844,22 +8833,7 @@ static void igb_deliver_wake_packet(struct net_device *netdev) | |||
| 8844 | 8833 | ||
| 8845 | static int __maybe_unused igb_suspend(struct device *dev) | 8834 | static int __maybe_unused igb_suspend(struct device *dev) |
| 8846 | { | 8835 | { |
| 8847 | int retval; | 8836 | return __igb_shutdown(to_pci_dev(dev), NULL, 0); |
| 8848 | bool wake; | ||
| 8849 | struct pci_dev *pdev = to_pci_dev(dev); | ||
| 8850 | |||
| 8851 | retval = __igb_shutdown(pdev, &wake, 0); | ||
| 8852 | if (retval) | ||
| 8853 | return retval; | ||
| 8854 | |||
| 8855 | if (wake) { | ||
| 8856 | pci_prepare_to_sleep(pdev); | ||
| 8857 | } else { | ||
| 8858 | pci_wake_from_d3(pdev, false); | ||
| 8859 | pci_set_power_state(pdev, PCI_D3hot); | ||
| 8860 | } | ||
| 8861 | |||
| 8862 | return 0; | ||
| 8863 | } | 8837 | } |
| 8864 | 8838 | ||
| 8865 | static int __maybe_unused igb_resume(struct device *dev) | 8839 | static int __maybe_unused igb_resume(struct device *dev) |
| @@ -8930,22 +8904,7 @@ static int __maybe_unused igb_runtime_idle(struct device *dev) | |||
| 8930 | 8904 | ||
| 8931 | static int __maybe_unused igb_runtime_suspend(struct device *dev) | 8905 | static int __maybe_unused igb_runtime_suspend(struct device *dev) |
| 8932 | { | 8906 | { |
| 8933 | struct pci_dev *pdev = to_pci_dev(dev); | 8907 | return __igb_shutdown(to_pci_dev(dev), NULL, 1); |
| 8934 | int retval; | ||
| 8935 | bool wake; | ||
| 8936 | |||
| 8937 | retval = __igb_shutdown(pdev, &wake, 1); | ||
| 8938 | if (retval) | ||
| 8939 | return retval; | ||
| 8940 | |||
| 8941 | if (wake) { | ||
| 8942 | pci_prepare_to_sleep(pdev); | ||
| 8943 | } else { | ||
| 8944 | pci_wake_from_d3(pdev, false); | ||
| 8945 | pci_set_power_state(pdev, PCI_D3hot); | ||
| 8946 | } | ||
| 8947 | |||
| 8948 | return 0; | ||
| 8949 | } | 8908 | } |
| 8950 | 8909 | ||
| 8951 | static int __maybe_unused igb_runtime_resume(struct device *dev) | 8910 | static int __maybe_unused igb_runtime_resume(struct device *dev) |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c index cc4907f9ff02..2fb97967961c 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | |||
| @@ -905,13 +905,12 @@ s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw) | |||
| 905 | struct pci_dev *pdev = adapter->pdev; | 905 | struct pci_dev *pdev = adapter->pdev; |
| 906 | struct device *dev = &adapter->netdev->dev; | 906 | struct device *dev = &adapter->netdev->dev; |
| 907 | struct mii_bus *bus; | 907 | struct mii_bus *bus; |
| 908 | int err = -ENODEV; | ||
| 908 | 909 | ||
| 909 | adapter->mii_bus = devm_mdiobus_alloc(dev); | 910 | bus = devm_mdiobus_alloc(dev); |
| 910 | if (!adapter->mii_bus) | 911 | if (!bus) |
| 911 | return -ENOMEM; | 912 | return -ENOMEM; |
| 912 | 913 | ||
| 913 | bus = adapter->mii_bus; | ||
| 914 | |||
| 915 | switch (hw->device_id) { | 914 | switch (hw->device_id) { |
| 916 | /* C3000 SoCs */ | 915 | /* C3000 SoCs */ |
| 917 | case IXGBE_DEV_ID_X550EM_A_KR: | 916 | case IXGBE_DEV_ID_X550EM_A_KR: |
| @@ -949,12 +948,15 @@ s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw) | |||
| 949 | */ | 948 | */ |
| 950 | hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22; | 949 | hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22; |
| 951 | 950 | ||
| 952 | return mdiobus_register(bus); | 951 | err = mdiobus_register(bus); |
| 952 | if (!err) { | ||
| 953 | adapter->mii_bus = bus; | ||
| 954 | return 0; | ||
| 955 | } | ||
| 953 | 956 | ||
| 954 | ixgbe_no_mii_bus: | 957 | ixgbe_no_mii_bus: |
| 955 | devm_mdiobus_free(dev, bus); | 958 | devm_mdiobus_free(dev, bus); |
| 956 | adapter->mii_bus = NULL; | 959 | return err; |
| 957 | return -ENODEV; | ||
| 958 | } | 960 | } |
| 959 | 961 | ||
| 960 | /** | 962 | /** |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/port.c b/drivers/net/ethernet/mellanox/mlx5/core/en/port.c index 122927f3a600..d5e5afbdca6d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/port.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/port.c | |||
| @@ -96,9 +96,6 @@ int mlx5_port_query_eth_proto(struct mlx5_core_dev *dev, u8 port, bool ext, | |||
| 96 | if (!eproto) | 96 | if (!eproto) |
| 97 | return -EINVAL; | 97 | return -EINVAL; |
| 98 | 98 | ||
| 99 | if (ext != MLX5_CAP_PCAM_FEATURE(dev, ptys_extended_ethernet)) | ||
| 100 | return -EOPNOTSUPP; | ||
| 101 | |||
| 102 | err = mlx5_query_port_ptys(dev, out, sizeof(out), MLX5_PTYS_EN, port); | 99 | err = mlx5_query_port_ptys(dev, out, sizeof(out), MLX5_PTYS_EN, port); |
| 103 | if (err) | 100 | if (err) |
| 104 | return err; | 101 | return err; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c index eac245a93f91..4ab0d030b544 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c | |||
| @@ -122,7 +122,9 @@ out: | |||
| 122 | return err; | 122 | return err; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | /* xoff = ((301+2.16 * len [m]) * speed [Gbps] + 2.72 MTU [B]) */ | 125 | /* xoff = ((301+2.16 * len [m]) * speed [Gbps] + 2.72 MTU [B]) |
| 126 | * minimum speed value is 40Gbps | ||
| 127 | */ | ||
| 126 | static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu) | 128 | static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu) |
| 127 | { | 129 | { |
| 128 | u32 speed; | 130 | u32 speed; |
| @@ -130,10 +132,9 @@ static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu) | |||
| 130 | int err; | 132 | int err; |
| 131 | 133 | ||
| 132 | err = mlx5e_port_linkspeed(priv->mdev, &speed); | 134 | err = mlx5e_port_linkspeed(priv->mdev, &speed); |
| 133 | if (err) { | 135 | if (err) |
| 134 | mlx5_core_warn(priv->mdev, "cannot get port speed\n"); | 136 | speed = SPEED_40000; |
| 135 | return 0; | 137 | speed = max_t(u32, speed, SPEED_40000); |
| 136 | } | ||
| 137 | 138 | ||
| 138 | xoff = (301 + 216 * priv->dcbx.cable_len / 100) * speed / 1000 + 272 * mtu / 100; | 139 | xoff = (301 + 216 * priv->dcbx.cable_len / 100) * speed / 1000 + 272 * mtu / 100; |
| 139 | 140 | ||
| @@ -142,7 +143,7 @@ static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu) | |||
| 142 | } | 143 | } |
| 143 | 144 | ||
| 144 | static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer, | 145 | static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer, |
| 145 | u32 xoff, unsigned int mtu) | 146 | u32 xoff, unsigned int max_mtu) |
| 146 | { | 147 | { |
| 147 | int i; | 148 | int i; |
| 148 | 149 | ||
| @@ -154,11 +155,12 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer, | |||
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | if (port_buffer->buffer[i].size < | 157 | if (port_buffer->buffer[i].size < |
| 157 | (xoff + mtu + (1 << MLX5E_BUFFER_CELL_SHIFT))) | 158 | (xoff + max_mtu + (1 << MLX5E_BUFFER_CELL_SHIFT))) |
| 158 | return -ENOMEM; | 159 | return -ENOMEM; |
| 159 | 160 | ||
| 160 | port_buffer->buffer[i].xoff = port_buffer->buffer[i].size - xoff; | 161 | port_buffer->buffer[i].xoff = port_buffer->buffer[i].size - xoff; |
| 161 | port_buffer->buffer[i].xon = port_buffer->buffer[i].xoff - mtu; | 162 | port_buffer->buffer[i].xon = |
| 163 | port_buffer->buffer[i].xoff - max_mtu; | ||
| 162 | } | 164 | } |
| 163 | 165 | ||
| 164 | return 0; | 166 | return 0; |
| @@ -166,7 +168,7 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer, | |||
| 166 | 168 | ||
| 167 | /** | 169 | /** |
| 168 | * update_buffer_lossy() | 170 | * update_buffer_lossy() |
| 169 | * mtu: device's MTU | 171 | * max_mtu: netdev's max_mtu |
| 170 | * pfc_en: <input> current pfc configuration | 172 | * pfc_en: <input> current pfc configuration |
| 171 | * buffer: <input> current prio to buffer mapping | 173 | * buffer: <input> current prio to buffer mapping |
| 172 | * xoff: <input> xoff value | 174 | * xoff: <input> xoff value |
| @@ -183,7 +185,7 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer, | |||
| 183 | * Return 0 if no error. | 185 | * Return 0 if no error. |
| 184 | * Set change to true if buffer configuration is modified. | 186 | * Set change to true if buffer configuration is modified. |
| 185 | */ | 187 | */ |
| 186 | static int update_buffer_lossy(unsigned int mtu, | 188 | static int update_buffer_lossy(unsigned int max_mtu, |
| 187 | u8 pfc_en, u8 *buffer, u32 xoff, | 189 | u8 pfc_en, u8 *buffer, u32 xoff, |
| 188 | struct mlx5e_port_buffer *port_buffer, | 190 | struct mlx5e_port_buffer *port_buffer, |
| 189 | bool *change) | 191 | bool *change) |
| @@ -220,7 +222,7 @@ static int update_buffer_lossy(unsigned int mtu, | |||
| 220 | } | 222 | } |
| 221 | 223 | ||
| 222 | if (changed) { | 224 | if (changed) { |
| 223 | err = update_xoff_threshold(port_buffer, xoff, mtu); | 225 | err = update_xoff_threshold(port_buffer, xoff, max_mtu); |
| 224 | if (err) | 226 | if (err) |
| 225 | return err; | 227 | return err; |
| 226 | 228 | ||
| @@ -230,6 +232,7 @@ static int update_buffer_lossy(unsigned int mtu, | |||
| 230 | return 0; | 232 | return 0; |
| 231 | } | 233 | } |
| 232 | 234 | ||
| 235 | #define MINIMUM_MAX_MTU 9216 | ||
| 233 | int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv, | 236 | int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv, |
| 234 | u32 change, unsigned int mtu, | 237 | u32 change, unsigned int mtu, |
| 235 | struct ieee_pfc *pfc, | 238 | struct ieee_pfc *pfc, |
| @@ -241,12 +244,14 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv, | |||
| 241 | bool update_prio2buffer = false; | 244 | bool update_prio2buffer = false; |
| 242 | u8 buffer[MLX5E_MAX_PRIORITY]; | 245 | u8 buffer[MLX5E_MAX_PRIORITY]; |
| 243 | bool update_buffer = false; | 246 | bool update_buffer = false; |
| 247 | unsigned int max_mtu; | ||
| 244 | u32 total_used = 0; | 248 | u32 total_used = 0; |
| 245 | u8 curr_pfc_en; | 249 | u8 curr_pfc_en; |
| 246 | int err; | 250 | int err; |
| 247 | int i; | 251 | int i; |
| 248 | 252 | ||
| 249 | mlx5e_dbg(HW, priv, "%s: change=%x\n", __func__, change); | 253 | mlx5e_dbg(HW, priv, "%s: change=%x\n", __func__, change); |
| 254 | max_mtu = max_t(unsigned int, priv->netdev->max_mtu, MINIMUM_MAX_MTU); | ||
| 250 | 255 | ||
| 251 | err = mlx5e_port_query_buffer(priv, &port_buffer); | 256 | err = mlx5e_port_query_buffer(priv, &port_buffer); |
| 252 | if (err) | 257 | if (err) |
| @@ -254,7 +259,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv, | |||
| 254 | 259 | ||
| 255 | if (change & MLX5E_PORT_BUFFER_CABLE_LEN) { | 260 | if (change & MLX5E_PORT_BUFFER_CABLE_LEN) { |
| 256 | update_buffer = true; | 261 | update_buffer = true; |
| 257 | err = update_xoff_threshold(&port_buffer, xoff, mtu); | 262 | err = update_xoff_threshold(&port_buffer, xoff, max_mtu); |
| 258 | if (err) | 263 | if (err) |
| 259 | return err; | 264 | return err; |
| 260 | } | 265 | } |
| @@ -264,7 +269,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv, | |||
| 264 | if (err) | 269 | if (err) |
| 265 | return err; | 270 | return err; |
| 266 | 271 | ||
| 267 | err = update_buffer_lossy(mtu, pfc->pfc_en, buffer, xoff, | 272 | err = update_buffer_lossy(max_mtu, pfc->pfc_en, buffer, xoff, |
| 268 | &port_buffer, &update_buffer); | 273 | &port_buffer, &update_buffer); |
| 269 | if (err) | 274 | if (err) |
| 270 | return err; | 275 | return err; |
| @@ -276,8 +281,8 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv, | |||
| 276 | if (err) | 281 | if (err) |
| 277 | return err; | 282 | return err; |
| 278 | 283 | ||
| 279 | err = update_buffer_lossy(mtu, curr_pfc_en, prio2buffer, xoff, | 284 | err = update_buffer_lossy(max_mtu, curr_pfc_en, prio2buffer, |
| 280 | &port_buffer, &update_buffer); | 285 | xoff, &port_buffer, &update_buffer); |
| 281 | if (err) | 286 | if (err) |
| 282 | return err; | 287 | return err; |
| 283 | } | 288 | } |
| @@ -301,7 +306,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv, | |||
| 301 | return -EINVAL; | 306 | return -EINVAL; |
| 302 | 307 | ||
| 303 | update_buffer = true; | 308 | update_buffer = true; |
| 304 | err = update_xoff_threshold(&port_buffer, xoff, mtu); | 309 | err = update_xoff_threshold(&port_buffer, xoff, max_mtu); |
| 305 | if (err) | 310 | if (err) |
| 306 | return err; | 311 | return err; |
| 307 | } | 312 | } |
| @@ -309,7 +314,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv, | |||
| 309 | /* Need to update buffer configuration if xoff value is changed */ | 314 | /* Need to update buffer configuration if xoff value is changed */ |
| 310 | if (!update_buffer && xoff != priv->dcbx.xoff) { | 315 | if (!update_buffer && xoff != priv->dcbx.xoff) { |
| 311 | update_buffer = true; | 316 | update_buffer = true; |
| 312 | err = update_xoff_threshold(&port_buffer, xoff, mtu); | 317 | err = update_xoff_threshold(&port_buffer, xoff, max_mtu); |
| 313 | if (err) | 318 | if (err) |
| 314 | return err; | 319 | return err; |
| 315 | } | 320 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c index 3078491cc0d0..1539cf3de5dc 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c | |||
| @@ -45,7 +45,9 @@ int mlx5e_create_tir(struct mlx5_core_dev *mdev, | |||
| 45 | if (err) | 45 | if (err) |
| 46 | return err; | 46 | return err; |
| 47 | 47 | ||
| 48 | mutex_lock(&mdev->mlx5e_res.td.list_lock); | ||
| 48 | list_add(&tir->list, &mdev->mlx5e_res.td.tirs_list); | 49 | list_add(&tir->list, &mdev->mlx5e_res.td.tirs_list); |
| 50 | mutex_unlock(&mdev->mlx5e_res.td.list_lock); | ||
| 49 | 51 | ||
| 50 | return 0; | 52 | return 0; |
| 51 | } | 53 | } |
| @@ -53,8 +55,10 @@ int mlx5e_create_tir(struct mlx5_core_dev *mdev, | |||
| 53 | void mlx5e_destroy_tir(struct mlx5_core_dev *mdev, | 55 | void mlx5e_destroy_tir(struct mlx5_core_dev *mdev, |
| 54 | struct mlx5e_tir *tir) | 56 | struct mlx5e_tir *tir) |
| 55 | { | 57 | { |
| 58 | mutex_lock(&mdev->mlx5e_res.td.list_lock); | ||
| 56 | mlx5_core_destroy_tir(mdev, tir->tirn); | 59 | mlx5_core_destroy_tir(mdev, tir->tirn); |
| 57 | list_del(&tir->list); | 60 | list_del(&tir->list); |
| 61 | mutex_unlock(&mdev->mlx5e_res.td.list_lock); | ||
| 58 | } | 62 | } |
| 59 | 63 | ||
| 60 | static int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn, | 64 | static int mlx5e_create_mkey(struct mlx5_core_dev *mdev, u32 pdn, |
| @@ -114,6 +118,7 @@ int mlx5e_create_mdev_resources(struct mlx5_core_dev *mdev) | |||
| 114 | } | 118 | } |
| 115 | 119 | ||
| 116 | INIT_LIST_HEAD(&mdev->mlx5e_res.td.tirs_list); | 120 | INIT_LIST_HEAD(&mdev->mlx5e_res.td.tirs_list); |
| 121 | mutex_init(&mdev->mlx5e_res.td.list_lock); | ||
| 117 | 122 | ||
| 118 | return 0; | 123 | return 0; |
| 119 | 124 | ||
| @@ -141,15 +146,17 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb) | |||
| 141 | { | 146 | { |
| 142 | struct mlx5_core_dev *mdev = priv->mdev; | 147 | struct mlx5_core_dev *mdev = priv->mdev; |
| 143 | struct mlx5e_tir *tir; | 148 | struct mlx5e_tir *tir; |
| 144 | int err = -ENOMEM; | 149 | int err = 0; |
| 145 | u32 tirn = 0; | 150 | u32 tirn = 0; |
| 146 | int inlen; | 151 | int inlen; |
| 147 | void *in; | 152 | void *in; |
| 148 | 153 | ||
| 149 | inlen = MLX5_ST_SZ_BYTES(modify_tir_in); | 154 | inlen = MLX5_ST_SZ_BYTES(modify_tir_in); |
| 150 | in = kvzalloc(inlen, GFP_KERNEL); | 155 | in = kvzalloc(inlen, GFP_KERNEL); |
| 151 | if (!in) | 156 | if (!in) { |
| 157 | err = -ENOMEM; | ||
| 152 | goto out; | 158 | goto out; |
| 159 | } | ||
| 153 | 160 | ||
| 154 | if (enable_uc_lb) | 161 | if (enable_uc_lb) |
| 155 | MLX5_SET(modify_tir_in, in, ctx.self_lb_block, | 162 | MLX5_SET(modify_tir_in, in, ctx.self_lb_block, |
| @@ -157,6 +164,7 @@ int mlx5e_refresh_tirs(struct mlx5e_priv *priv, bool enable_uc_lb) | |||
| 157 | 164 | ||
| 158 | MLX5_SET(modify_tir_in, in, bitmask.self_lb_en, 1); | 165 | MLX5_SET(modify_tir_in, in, bitmask.self_lb_en, 1); |
| 159 | 166 | ||
| 167 | mutex_lock(&mdev->mlx5e_res.td.list_lock); | ||
| 160 | list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) { | 168 | list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) { |
| 161 | tirn = tir->tirn; | 169 | tirn = tir->tirn; |
| 162 | err = mlx5_core_modify_tir(mdev, tirn, in, inlen); | 170 | err = mlx5_core_modify_tir(mdev, tirn, in, inlen); |
| @@ -168,6 +176,7 @@ out: | |||
| 168 | kvfree(in); | 176 | kvfree(in); |
| 169 | if (err) | 177 | if (err) |
| 170 | netdev_err(priv->netdev, "refresh tir(0x%x) failed, %d\n", tirn, err); | 178 | netdev_err(priv->netdev, "refresh tir(0x%x) failed, %d\n", tirn, err); |
| 179 | mutex_unlock(&mdev->mlx5e_res.td.list_lock); | ||
| 171 | 180 | ||
| 172 | return err; | 181 | return err; |
| 173 | } | 182 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index a0987cc5fe4a..5efce4a3ff79 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | |||
| @@ -603,16 +603,18 @@ static void ptys2ethtool_supported_link(struct mlx5_core_dev *mdev, | |||
| 603 | __ETHTOOL_LINK_MODE_MASK_NBITS); | 603 | __ETHTOOL_LINK_MODE_MASK_NBITS); |
| 604 | } | 604 | } |
| 605 | 605 | ||
| 606 | static void ptys2ethtool_adver_link(struct mlx5_core_dev *mdev, | 606 | static void ptys2ethtool_adver_link(unsigned long *advertising_modes, |
| 607 | unsigned long *advertising_modes, | 607 | u32 eth_proto_cap, bool ext) |
| 608 | u32 eth_proto_cap) | ||
| 609 | { | 608 | { |
| 610 | unsigned long proto_cap = eth_proto_cap; | 609 | unsigned long proto_cap = eth_proto_cap; |
| 611 | struct ptys2ethtool_config *table; | 610 | struct ptys2ethtool_config *table; |
| 612 | u32 max_size; | 611 | u32 max_size; |
| 613 | int proto; | 612 | int proto; |
| 614 | 613 | ||
| 615 | mlx5e_ethtool_get_speed_arr(mdev, &table, &max_size); | 614 | table = ext ? ptys2ext_ethtool_table : ptys2legacy_ethtool_table; |
| 615 | max_size = ext ? ARRAY_SIZE(ptys2ext_ethtool_table) : | ||
| 616 | ARRAY_SIZE(ptys2legacy_ethtool_table); | ||
| 617 | |||
| 616 | for_each_set_bit(proto, &proto_cap, max_size) | 618 | for_each_set_bit(proto, &proto_cap, max_size) |
| 617 | bitmap_or(advertising_modes, advertising_modes, | 619 | bitmap_or(advertising_modes, advertising_modes, |
| 618 | table[proto].advertised, | 620 | table[proto].advertised, |
| @@ -794,12 +796,12 @@ static void get_supported(struct mlx5_core_dev *mdev, u32 eth_proto_cap, | |||
| 794 | ethtool_link_ksettings_add_link_mode(link_ksettings, supported, Pause); | 796 | ethtool_link_ksettings_add_link_mode(link_ksettings, supported, Pause); |
| 795 | } | 797 | } |
| 796 | 798 | ||
| 797 | static void get_advertising(struct mlx5_core_dev *mdev, u32 eth_proto_cap, | 799 | static void get_advertising(u32 eth_proto_cap, u8 tx_pause, u8 rx_pause, |
| 798 | u8 tx_pause, u8 rx_pause, | 800 | struct ethtool_link_ksettings *link_ksettings, |
| 799 | struct ethtool_link_ksettings *link_ksettings) | 801 | bool ext) |
| 800 | { | 802 | { |
| 801 | unsigned long *advertising = link_ksettings->link_modes.advertising; | 803 | unsigned long *advertising = link_ksettings->link_modes.advertising; |
| 802 | ptys2ethtool_adver_link(mdev, advertising, eth_proto_cap); | 804 | ptys2ethtool_adver_link(advertising, eth_proto_cap, ext); |
| 803 | 805 | ||
| 804 | if (rx_pause) | 806 | if (rx_pause) |
| 805 | ethtool_link_ksettings_add_link_mode(link_ksettings, advertising, Pause); | 807 | ethtool_link_ksettings_add_link_mode(link_ksettings, advertising, Pause); |
| @@ -854,8 +856,9 @@ static void get_lp_advertising(struct mlx5_core_dev *mdev, u32 eth_proto_lp, | |||
| 854 | struct ethtool_link_ksettings *link_ksettings) | 856 | struct ethtool_link_ksettings *link_ksettings) |
| 855 | { | 857 | { |
| 856 | unsigned long *lp_advertising = link_ksettings->link_modes.lp_advertising; | 858 | unsigned long *lp_advertising = link_ksettings->link_modes.lp_advertising; |
| 859 | bool ext = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); | ||
| 857 | 860 | ||
| 858 | ptys2ethtool_adver_link(mdev, lp_advertising, eth_proto_lp); | 861 | ptys2ethtool_adver_link(lp_advertising, eth_proto_lp, ext); |
| 859 | } | 862 | } |
| 860 | 863 | ||
| 861 | int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv, | 864 | int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv, |
| @@ -872,6 +875,7 @@ int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv, | |||
| 872 | u8 an_disable_admin; | 875 | u8 an_disable_admin; |
| 873 | u8 an_status; | 876 | u8 an_status; |
| 874 | u8 connector_type; | 877 | u8 connector_type; |
| 878 | bool admin_ext; | ||
| 875 | bool ext; | 879 | bool ext; |
| 876 | int err; | 880 | int err; |
| 877 | 881 | ||
| @@ -886,6 +890,19 @@ int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv, | |||
| 886 | eth_proto_capability); | 890 | eth_proto_capability); |
| 887 | eth_proto_admin = MLX5_GET_ETH_PROTO(ptys_reg, out, ext, | 891 | eth_proto_admin = MLX5_GET_ETH_PROTO(ptys_reg, out, ext, |
| 888 | eth_proto_admin); | 892 | eth_proto_admin); |
| 893 | /* Fields: eth_proto_admin and ext_eth_proto_admin are | ||
| 894 | * mutually exclusive. Hence try reading legacy advertising | ||
| 895 | * when extended advertising is zero. | ||
| 896 | * admin_ext indicates how eth_proto_admin should be | ||
| 897 | * interpreted | ||
| 898 | */ | ||
| 899 | admin_ext = ext; | ||
| 900 | if (ext && !eth_proto_admin) { | ||
| 901 | eth_proto_admin = MLX5_GET_ETH_PROTO(ptys_reg, out, false, | ||
| 902 | eth_proto_admin); | ||
| 903 | admin_ext = false; | ||
| 904 | } | ||
| 905 | |||
| 889 | eth_proto_oper = MLX5_GET_ETH_PROTO(ptys_reg, out, ext, | 906 | eth_proto_oper = MLX5_GET_ETH_PROTO(ptys_reg, out, ext, |
| 890 | eth_proto_oper); | 907 | eth_proto_oper); |
| 891 | eth_proto_lp = MLX5_GET(ptys_reg, out, eth_proto_lp_advertise); | 908 | eth_proto_lp = MLX5_GET(ptys_reg, out, eth_proto_lp_advertise); |
| @@ -899,7 +916,8 @@ int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv, | |||
| 899 | ethtool_link_ksettings_zero_link_mode(link_ksettings, advertising); | 916 | ethtool_link_ksettings_zero_link_mode(link_ksettings, advertising); |
| 900 | 917 | ||
| 901 | get_supported(mdev, eth_proto_cap, link_ksettings); | 918 | get_supported(mdev, eth_proto_cap, link_ksettings); |
| 902 | get_advertising(mdev, eth_proto_admin, tx_pause, rx_pause, link_ksettings); | 919 | get_advertising(eth_proto_admin, tx_pause, rx_pause, link_ksettings, |
| 920 | admin_ext); | ||
| 903 | get_speed_duplex(priv->netdev, eth_proto_oper, link_ksettings); | 921 | get_speed_duplex(priv->netdev, eth_proto_oper, link_ksettings); |
| 904 | 922 | ||
| 905 | eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap; | 923 | eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap; |
| @@ -997,19 +1015,17 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, | |||
| 997 | 1015 | ||
| 998 | #define MLX5E_PTYS_EXT ((1ULL << ETHTOOL_LINK_MODE_50000baseKR_Full_BIT) - 1) | 1016 | #define MLX5E_PTYS_EXT ((1ULL << ETHTOOL_LINK_MODE_50000baseKR_Full_BIT) - 1) |
| 999 | 1017 | ||
| 1000 | ext_requested = (link_ksettings->link_modes.advertising[0] > | 1018 | ext_requested = !!(link_ksettings->link_modes.advertising[0] > |
| 1001 | MLX5E_PTYS_EXT); | 1019 | MLX5E_PTYS_EXT || |
| 1020 | link_ksettings->link_modes.advertising[1]); | ||
| 1002 | ext_supported = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); | 1021 | ext_supported = MLX5_CAP_PCAM_FEATURE(mdev, ptys_extended_ethernet); |
| 1003 | 1022 | ext_requested &= ext_supported; | |
| 1004 | /*when ptys_extended_ethernet is set legacy link modes are deprecated */ | ||
| 1005 | if (ext_requested != ext_supported) | ||
| 1006 | return -EPROTONOSUPPORT; | ||
| 1007 | 1023 | ||
| 1008 | speed = link_ksettings->base.speed; | 1024 | speed = link_ksettings->base.speed; |
| 1009 | ethtool2ptys_adver_func = ext_requested ? | 1025 | ethtool2ptys_adver_func = ext_requested ? |
| 1010 | mlx5e_ethtool2ptys_ext_adver_link : | 1026 | mlx5e_ethtool2ptys_ext_adver_link : |
| 1011 | mlx5e_ethtool2ptys_adver_link; | 1027 | mlx5e_ethtool2ptys_adver_link; |
| 1012 | err = mlx5_port_query_eth_proto(mdev, 1, ext_supported, &eproto); | 1028 | err = mlx5_port_query_eth_proto(mdev, 1, ext_requested, &eproto); |
| 1013 | if (err) { | 1029 | if (err) { |
| 1014 | netdev_err(priv->netdev, "%s: query port eth proto failed: %d\n", | 1030 | netdev_err(priv->netdev, "%s: query port eth proto failed: %d\n", |
| 1015 | __func__, err); | 1031 | __func__, err); |
| @@ -1037,7 +1053,7 @@ int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv, | |||
| 1037 | if (!an_changes && link_modes == eproto.admin) | 1053 | if (!an_changes && link_modes == eproto.admin) |
| 1038 | goto out; | 1054 | goto out; |
| 1039 | 1055 | ||
| 1040 | mlx5_port_set_eth_ptys(mdev, an_disable, link_modes, ext_supported); | 1056 | mlx5_port_set_eth_ptys(mdev, an_disable, link_modes, ext_requested); |
| 1041 | mlx5_toggle_port_link(mdev); | 1057 | mlx5_toggle_port_link(mdev); |
| 1042 | 1058 | ||
| 1043 | out: | 1059 | out: |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index b4967a0ff8c7..d75dc44eb2ff 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | |||
| @@ -2158,6 +2158,52 @@ static bool csum_offload_supported(struct mlx5e_priv *priv, | |||
| 2158 | return true; | 2158 | return true; |
| 2159 | } | 2159 | } |
| 2160 | 2160 | ||
| 2161 | struct ip_ttl_word { | ||
| 2162 | __u8 ttl; | ||
| 2163 | __u8 protocol; | ||
| 2164 | __sum16 check; | ||
| 2165 | }; | ||
| 2166 | |||
| 2167 | struct ipv6_hoplimit_word { | ||
| 2168 | __be16 payload_len; | ||
| 2169 | __u8 nexthdr; | ||
| 2170 | __u8 hop_limit; | ||
| 2171 | }; | ||
| 2172 | |||
| 2173 | static bool is_action_keys_supported(const struct flow_action_entry *act) | ||
| 2174 | { | ||
| 2175 | u32 mask, offset; | ||
| 2176 | u8 htype; | ||
| 2177 | |||
| 2178 | htype = act->mangle.htype; | ||
| 2179 | offset = act->mangle.offset; | ||
| 2180 | mask = ~act->mangle.mask; | ||
| 2181 | /* For IPv4 & IPv6 header check 4 byte word, | ||
| 2182 | * to determine that modified fields | ||
| 2183 | * are NOT ttl & hop_limit only. | ||
| 2184 | */ | ||
| 2185 | if (htype == FLOW_ACT_MANGLE_HDR_TYPE_IP4) { | ||
| 2186 | struct ip_ttl_word *ttl_word = | ||
| 2187 | (struct ip_ttl_word *)&mask; | ||
| 2188 | |||
| 2189 | if (offset != offsetof(struct iphdr, ttl) || | ||
| 2190 | ttl_word->protocol || | ||
| 2191 | ttl_word->check) { | ||
| 2192 | return true; | ||
| 2193 | } | ||
| 2194 | } else if (htype == FLOW_ACT_MANGLE_HDR_TYPE_IP6) { | ||
| 2195 | struct ipv6_hoplimit_word *hoplimit_word = | ||
| 2196 | (struct ipv6_hoplimit_word *)&mask; | ||
| 2197 | |||
| 2198 | if (offset != offsetof(struct ipv6hdr, payload_len) || | ||
| 2199 | hoplimit_word->payload_len || | ||
| 2200 | hoplimit_word->nexthdr) { | ||
| 2201 | return true; | ||
| 2202 | } | ||
| 2203 | } | ||
| 2204 | return false; | ||
| 2205 | } | ||
| 2206 | |||
| 2161 | static bool modify_header_match_supported(struct mlx5_flow_spec *spec, | 2207 | static bool modify_header_match_supported(struct mlx5_flow_spec *spec, |
| 2162 | struct flow_action *flow_action, | 2208 | struct flow_action *flow_action, |
| 2163 | u32 actions, | 2209 | u32 actions, |
| @@ -2165,9 +2211,9 @@ static bool modify_header_match_supported(struct mlx5_flow_spec *spec, | |||
| 2165 | { | 2211 | { |
| 2166 | const struct flow_action_entry *act; | 2212 | const struct flow_action_entry *act; |
| 2167 | bool modify_ip_header; | 2213 | bool modify_ip_header; |
| 2168 | u8 htype, ip_proto; | ||
| 2169 | void *headers_v; | 2214 | void *headers_v; |
| 2170 | u16 ethertype; | 2215 | u16 ethertype; |
| 2216 | u8 ip_proto; | ||
| 2171 | int i; | 2217 | int i; |
| 2172 | 2218 | ||
| 2173 | if (actions & MLX5_FLOW_CONTEXT_ACTION_DECAP) | 2219 | if (actions & MLX5_FLOW_CONTEXT_ACTION_DECAP) |
| @@ -2187,9 +2233,7 @@ static bool modify_header_match_supported(struct mlx5_flow_spec *spec, | |||
| 2187 | act->id != FLOW_ACTION_ADD) | 2233 | act->id != FLOW_ACTION_ADD) |
| 2188 | continue; | 2234 | continue; |
| 2189 | 2235 | ||
| 2190 | htype = act->mangle.htype; | 2236 | if (is_action_keys_supported(act)) { |
| 2191 | if (htype == FLOW_ACT_MANGLE_HDR_TYPE_IP4 || | ||
| 2192 | htype == FLOW_ACT_MANGLE_HDR_TYPE_IP6) { | ||
| 2193 | modify_ip_header = true; | 2237 | modify_ip_header = true; |
| 2194 | break; | 2238 | break; |
| 2195 | } | 2239 | } |
| @@ -2340,15 +2384,22 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, | |||
| 2340 | return 0; | 2384 | return 0; |
| 2341 | } | 2385 | } |
| 2342 | 2386 | ||
| 2343 | static inline int cmp_encap_info(struct ip_tunnel_key *a, | 2387 | struct encap_key { |
| 2344 | struct ip_tunnel_key *b) | 2388 | struct ip_tunnel_key *ip_tun_key; |
| 2389 | int tunnel_type; | ||
| 2390 | }; | ||
| 2391 | |||
| 2392 | static inline int cmp_encap_info(struct encap_key *a, | ||
| 2393 | struct encap_key *b) | ||
| 2345 | { | 2394 | { |
| 2346 | return memcmp(a, b, sizeof(*a)); | 2395 | return memcmp(a->ip_tun_key, b->ip_tun_key, sizeof(*a->ip_tun_key)) || |
| 2396 | a->tunnel_type != b->tunnel_type; | ||
| 2347 | } | 2397 | } |
| 2348 | 2398 | ||
| 2349 | static inline int hash_encap_info(struct ip_tunnel_key *key) | 2399 | static inline int hash_encap_info(struct encap_key *key) |
| 2350 | { | 2400 | { |
| 2351 | return jhash(key, sizeof(*key), 0); | 2401 | return jhash(key->ip_tun_key, sizeof(*key->ip_tun_key), |
| 2402 | key->tunnel_type); | ||
| 2352 | } | 2403 | } |
| 2353 | 2404 | ||
| 2354 | 2405 | ||
| @@ -2379,7 +2430,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, | |||
| 2379 | struct mlx5_esw_flow_attr *attr = flow->esw_attr; | 2430 | struct mlx5_esw_flow_attr *attr = flow->esw_attr; |
| 2380 | struct mlx5e_tc_flow_parse_attr *parse_attr; | 2431 | struct mlx5e_tc_flow_parse_attr *parse_attr; |
| 2381 | struct ip_tunnel_info *tun_info; | 2432 | struct ip_tunnel_info *tun_info; |
| 2382 | struct ip_tunnel_key *key; | 2433 | struct encap_key key, e_key; |
| 2383 | struct mlx5e_encap_entry *e; | 2434 | struct mlx5e_encap_entry *e; |
| 2384 | unsigned short family; | 2435 | unsigned short family; |
| 2385 | uintptr_t hash_key; | 2436 | uintptr_t hash_key; |
| @@ -2389,13 +2440,16 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, | |||
| 2389 | parse_attr = attr->parse_attr; | 2440 | parse_attr = attr->parse_attr; |
| 2390 | tun_info = &parse_attr->tun_info[out_index]; | 2441 | tun_info = &parse_attr->tun_info[out_index]; |
| 2391 | family = ip_tunnel_info_af(tun_info); | 2442 | family = ip_tunnel_info_af(tun_info); |
| 2392 | key = &tun_info->key; | 2443 | key.ip_tun_key = &tun_info->key; |
| 2444 | key.tunnel_type = mlx5e_tc_tun_get_type(mirred_dev); | ||
| 2393 | 2445 | ||
| 2394 | hash_key = hash_encap_info(key); | 2446 | hash_key = hash_encap_info(&key); |
| 2395 | 2447 | ||
| 2396 | hash_for_each_possible_rcu(esw->offloads.encap_tbl, e, | 2448 | hash_for_each_possible_rcu(esw->offloads.encap_tbl, e, |
| 2397 | encap_hlist, hash_key) { | 2449 | encap_hlist, hash_key) { |
| 2398 | if (!cmp_encap_info(&e->tun_info.key, key)) { | 2450 | e_key.ip_tun_key = &e->tun_info.key; |
| 2451 | e_key.tunnel_type = e->tunnel_type; | ||
| 2452 | if (!cmp_encap_info(&e_key, &key)) { | ||
| 2399 | found = true; | 2453 | found = true; |
| 2400 | break; | 2454 | break; |
| 2401 | } | 2455 | } |
| @@ -2657,7 +2711,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, | |||
| 2657 | 2711 | ||
| 2658 | if (hdrs[TCA_PEDIT_KEY_EX_CMD_SET].pedits || | 2712 | if (hdrs[TCA_PEDIT_KEY_EX_CMD_SET].pedits || |
| 2659 | hdrs[TCA_PEDIT_KEY_EX_CMD_ADD].pedits) { | 2713 | hdrs[TCA_PEDIT_KEY_EX_CMD_ADD].pedits) { |
| 2660 | err = alloc_tc_pedit_action(priv, MLX5_FLOW_NAMESPACE_KERNEL, | 2714 | err = alloc_tc_pedit_action(priv, MLX5_FLOW_NAMESPACE_FDB, |
| 2661 | parse_attr, hdrs, extack); | 2715 | parse_attr, hdrs, extack); |
| 2662 | if (err) | 2716 | if (err) |
| 2663 | return err; | 2717 | return err; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index ecd2c747f726..8a67fd197b79 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | |||
| @@ -105,8 +105,7 @@ static int arm_vport_context_events_cmd(struct mlx5_core_dev *dev, u16 vport, | |||
| 105 | opcode, MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); | 105 | opcode, MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT); |
| 106 | MLX5_SET(modify_nic_vport_context_in, in, field_select.change_event, 1); | 106 | MLX5_SET(modify_nic_vport_context_in, in, field_select.change_event, 1); |
| 107 | MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport); | 107 | MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport); |
| 108 | if (vport) | 108 | MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1); |
| 109 | MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1); | ||
| 110 | nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, | 109 | nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, |
| 111 | in, nic_vport_context); | 110 | in, nic_vport_context); |
| 112 | 111 | ||
| @@ -134,8 +133,7 @@ static int modify_esw_vport_context_cmd(struct mlx5_core_dev *dev, u16 vport, | |||
| 134 | MLX5_SET(modify_esw_vport_context_in, in, opcode, | 133 | MLX5_SET(modify_esw_vport_context_in, in, opcode, |
| 135 | MLX5_CMD_OP_MODIFY_ESW_VPORT_CONTEXT); | 134 | MLX5_CMD_OP_MODIFY_ESW_VPORT_CONTEXT); |
| 136 | MLX5_SET(modify_esw_vport_context_in, in, vport_number, vport); | 135 | MLX5_SET(modify_esw_vport_context_in, in, vport_number, vport); |
| 137 | if (vport) | 136 | MLX5_SET(modify_esw_vport_context_in, in, other_vport, 1); |
| 138 | MLX5_SET(modify_esw_vport_context_in, in, other_vport, 1); | ||
| 139 | return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); | 137 | return mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); |
| 140 | } | 138 | } |
| 141 | 139 | ||
| @@ -431,6 +429,8 @@ static int esw_create_legacy_table(struct mlx5_eswitch *esw) | |||
| 431 | { | 429 | { |
| 432 | int err; | 430 | int err; |
| 433 | 431 | ||
| 432 | memset(&esw->fdb_table.legacy, 0, sizeof(struct legacy_fdb)); | ||
| 433 | |||
| 434 | err = esw_create_legacy_vepa_table(esw); | 434 | err = esw_create_legacy_vepa_table(esw); |
| 435 | if (err) | 435 | if (err) |
| 436 | return err; | 436 | return err; |
| @@ -2157,6 +2157,7 @@ static int _mlx5_eswitch_set_vepa_locked(struct mlx5_eswitch *esw, | |||
| 2157 | 2157 | ||
| 2158 | /* Star rule to forward all traffic to uplink vport */ | 2158 | /* Star rule to forward all traffic to uplink vport */ |
| 2159 | memset(spec, 0, sizeof(*spec)); | 2159 | memset(spec, 0, sizeof(*spec)); |
| 2160 | memset(&dest, 0, sizeof(dest)); | ||
| 2160 | dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT; | 2161 | dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT; |
| 2161 | dest.vport.num = MLX5_VPORT_UPLINK; | 2162 | dest.vport.num = MLX5_VPORT_UPLINK; |
| 2162 | flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; | 2163 | flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c index f2260391be5b..9b2d78ee22b8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | |||
| @@ -1611,6 +1611,7 @@ static int esw_offloads_steering_init(struct mlx5_eswitch *esw, int nvports) | |||
| 1611 | { | 1611 | { |
| 1612 | int err; | 1612 | int err; |
| 1613 | 1613 | ||
| 1614 | memset(&esw->fdb_table.offloads, 0, sizeof(struct offloads_fdb)); | ||
| 1614 | mutex_init(&esw->fdb_table.offloads.fdb_prio_lock); | 1615 | mutex_init(&esw->fdb_table.offloads.fdb_prio_lock); |
| 1615 | 1616 | ||
| 1616 | err = esw_create_offloads_fdb_tables(esw, nvports); | 1617 | err = esw_create_offloads_fdb_tables(esw, nvports); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c index 5cf5f2a9d51f..8de64e88c670 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c | |||
| @@ -217,15 +217,21 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq, | |||
| 217 | void *cmd; | 217 | void *cmd; |
| 218 | int ret; | 218 | int ret; |
| 219 | 219 | ||
| 220 | rcu_read_lock(); | ||
| 221 | flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle)); | ||
| 222 | rcu_read_unlock(); | ||
| 223 | |||
| 224 | if (!flow) { | ||
| 225 | WARN_ONCE(1, "Received NULL pointer for handle\n"); | ||
| 226 | return -EINVAL; | ||
| 227 | } | ||
| 228 | |||
| 220 | buf = kzalloc(size, GFP_ATOMIC); | 229 | buf = kzalloc(size, GFP_ATOMIC); |
| 221 | if (!buf) | 230 | if (!buf) |
| 222 | return -ENOMEM; | 231 | return -ENOMEM; |
| 223 | 232 | ||
| 224 | cmd = (buf + 1); | 233 | cmd = (buf + 1); |
| 225 | 234 | ||
| 226 | rcu_read_lock(); | ||
| 227 | flow = idr_find(&mdev->fpga->tls->rx_idr, ntohl(handle)); | ||
| 228 | rcu_read_unlock(); | ||
| 229 | mlx5_fpga_tls_flow_to_cmd(flow, cmd); | 235 | mlx5_fpga_tls_flow_to_cmd(flow, cmd); |
| 230 | 236 | ||
| 231 | MLX5_SET(tls_cmd, cmd, swid, ntohl(handle)); | 237 | MLX5_SET(tls_cmd, cmd, swid, ntohl(handle)); |
| @@ -238,6 +244,8 @@ int mlx5_fpga_tls_resync_rx(struct mlx5_core_dev *mdev, u32 handle, u32 seq, | |||
| 238 | buf->complete = mlx_tls_kfree_complete; | 244 | buf->complete = mlx_tls_kfree_complete; |
| 239 | 245 | ||
| 240 | ret = mlx5_fpga_sbu_conn_sendmsg(mdev->fpga->tls->conn, buf); | 246 | ret = mlx5_fpga_sbu_conn_sendmsg(mdev->fpga->tls->conn, buf); |
| 247 | if (ret < 0) | ||
| 248 | kfree(buf); | ||
| 241 | 249 | ||
| 242 | return ret; | 250 | return ret; |
| 243 | } | 251 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index 70cc906a102b..76716419370d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c | |||
| @@ -164,26 +164,6 @@ static struct mlx5_profile profile[] = { | |||
| 164 | .size = 8, | 164 | .size = 8, |
| 165 | .limit = 4 | 165 | .limit = 4 |
| 166 | }, | 166 | }, |
| 167 | .mr_cache[16] = { | ||
| 168 | .size = 8, | ||
| 169 | .limit = 4 | ||
| 170 | }, | ||
| 171 | .mr_cache[17] = { | ||
| 172 | .size = 8, | ||
| 173 | .limit = 4 | ||
| 174 | }, | ||
| 175 | .mr_cache[18] = { | ||
| 176 | .size = 8, | ||
| 177 | .limit = 4 | ||
| 178 | }, | ||
| 179 | .mr_cache[19] = { | ||
| 180 | .size = 4, | ||
| 181 | .limit = 2 | ||
| 182 | }, | ||
| 183 | .mr_cache[20] = { | ||
| 184 | .size = 4, | ||
| 185 | .limit = 2 | ||
| 186 | }, | ||
| 187 | }, | 167 | }, |
| 188 | }; | 168 | }; |
| 189 | 169 | ||
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_env.c b/drivers/net/ethernet/mellanox/mlxsw/core_env.c index 7a15e932ed2f..c1c1965d7acc 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_env.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_env.c | |||
| @@ -113,7 +113,7 @@ int mlxsw_env_module_temp_thresholds_get(struct mlxsw_core *core, int module, | |||
| 113 | return 0; | 113 | return 0; |
| 114 | default: | 114 | default: |
| 115 | /* Do not consider thresholds for zero temperature. */ | 115 | /* Do not consider thresholds for zero temperature. */ |
| 116 | if (!MLXSW_REG_MTMP_TEMP_TO_MC(module_temp)) { | 116 | if (MLXSW_REG_MTMP_TEMP_TO_MC(module_temp) == 0) { |
| 117 | *temp = 0; | 117 | *temp = 0; |
| 118 | return 0; | 118 | return 0; |
| 119 | } | 119 | } |
diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index bd6e9014bc74..7849119d407a 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c | |||
| @@ -142,6 +142,12 @@ struct ks8851_net { | |||
| 142 | 142 | ||
| 143 | static int msg_enable; | 143 | static int msg_enable; |
| 144 | 144 | ||
| 145 | /* SPI frame opcodes */ | ||
| 146 | #define KS_SPIOP_RD (0x00) | ||
| 147 | #define KS_SPIOP_WR (0x40) | ||
| 148 | #define KS_SPIOP_RXFIFO (0x80) | ||
| 149 | #define KS_SPIOP_TXFIFO (0xC0) | ||
| 150 | |||
| 145 | /* shift for byte-enable data */ | 151 | /* shift for byte-enable data */ |
| 146 | #define BYTE_EN(_x) ((_x) << 2) | 152 | #define BYTE_EN(_x) ((_x) << 2) |
| 147 | 153 | ||
| @@ -535,9 +541,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) | |||
| 535 | /* set dma read address */ | 541 | /* set dma read address */ |
| 536 | ks8851_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI | 0x00); | 542 | ks8851_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI | 0x00); |
| 537 | 543 | ||
| 538 | /* start the packet dma process, and set auto-dequeue rx */ | 544 | /* start DMA access */ |
| 539 | ks8851_wrreg16(ks, KS_RXQCR, | 545 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); |
| 540 | ks->rc_rxqcr | RXQCR_SDA | RXQCR_ADRFE); | ||
| 541 | 546 | ||
| 542 | if (rxlen > 4) { | 547 | if (rxlen > 4) { |
| 543 | unsigned int rxalign; | 548 | unsigned int rxalign; |
| @@ -568,7 +573,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) | |||
| 568 | } | 573 | } |
| 569 | } | 574 | } |
| 570 | 575 | ||
| 571 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr); | 576 | /* end DMA access and dequeue packet */ |
| 577 | ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_RRXEF); | ||
| 572 | } | 578 | } |
| 573 | } | 579 | } |
| 574 | 580 | ||
| @@ -785,6 +791,15 @@ static void ks8851_tx_work(struct work_struct *work) | |||
| 785 | static int ks8851_net_open(struct net_device *dev) | 791 | static int ks8851_net_open(struct net_device *dev) |
| 786 | { | 792 | { |
| 787 | struct ks8851_net *ks = netdev_priv(dev); | 793 | struct ks8851_net *ks = netdev_priv(dev); |
| 794 | int ret; | ||
| 795 | |||
| 796 | ret = request_threaded_irq(dev->irq, NULL, ks8851_irq, | ||
| 797 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
| 798 | dev->name, ks); | ||
| 799 | if (ret < 0) { | ||
| 800 | netdev_err(dev, "failed to get irq\n"); | ||
| 801 | return ret; | ||
| 802 | } | ||
| 788 | 803 | ||
| 789 | /* lock the card, even if we may not actually be doing anything | 804 | /* lock the card, even if we may not actually be doing anything |
| 790 | * else at the moment */ | 805 | * else at the moment */ |
| @@ -849,6 +864,7 @@ static int ks8851_net_open(struct net_device *dev) | |||
| 849 | netif_dbg(ks, ifup, ks->netdev, "network device up\n"); | 864 | netif_dbg(ks, ifup, ks->netdev, "network device up\n"); |
| 850 | 865 | ||
| 851 | mutex_unlock(&ks->lock); | 866 | mutex_unlock(&ks->lock); |
| 867 | mii_check_link(&ks->mii); | ||
| 852 | return 0; | 868 | return 0; |
| 853 | } | 869 | } |
| 854 | 870 | ||
| @@ -899,6 +915,8 @@ static int ks8851_net_stop(struct net_device *dev) | |||
| 899 | dev_kfree_skb(txb); | 915 | dev_kfree_skb(txb); |
| 900 | } | 916 | } |
| 901 | 917 | ||
| 918 | free_irq(dev->irq, ks); | ||
| 919 | |||
| 902 | return 0; | 920 | return 0; |
| 903 | } | 921 | } |
| 904 | 922 | ||
| @@ -1508,6 +1526,7 @@ static int ks8851_probe(struct spi_device *spi) | |||
| 1508 | 1526 | ||
| 1509 | spi_set_drvdata(spi, ks); | 1527 | spi_set_drvdata(spi, ks); |
| 1510 | 1528 | ||
| 1529 | netif_carrier_off(ks->netdev); | ||
| 1511 | ndev->if_port = IF_PORT_100BASET; | 1530 | ndev->if_port = IF_PORT_100BASET; |
| 1512 | ndev->netdev_ops = &ks8851_netdev_ops; | 1531 | ndev->netdev_ops = &ks8851_netdev_ops; |
| 1513 | ndev->irq = spi->irq; | 1532 | ndev->irq = spi->irq; |
| @@ -1529,14 +1548,6 @@ static int ks8851_probe(struct spi_device *spi) | |||
| 1529 | ks8851_read_selftest(ks); | 1548 | ks8851_read_selftest(ks); |
| 1530 | ks8851_init_mac(ks); | 1549 | ks8851_init_mac(ks); |
| 1531 | 1550 | ||
| 1532 | ret = request_threaded_irq(spi->irq, NULL, ks8851_irq, | ||
| 1533 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | ||
| 1534 | ndev->name, ks); | ||
| 1535 | if (ret < 0) { | ||
| 1536 | dev_err(&spi->dev, "failed to get irq\n"); | ||
| 1537 | goto err_irq; | ||
| 1538 | } | ||
| 1539 | |||
| 1540 | ret = register_netdev(ndev); | 1551 | ret = register_netdev(ndev); |
| 1541 | if (ret) { | 1552 | if (ret) { |
| 1542 | dev_err(&spi->dev, "failed to register network device\n"); | 1553 | dev_err(&spi->dev, "failed to register network device\n"); |
| @@ -1549,14 +1560,10 @@ static int ks8851_probe(struct spi_device *spi) | |||
| 1549 | 1560 | ||
| 1550 | return 0; | 1561 | return 0; |
| 1551 | 1562 | ||
| 1552 | |||
| 1553 | err_netdev: | 1563 | err_netdev: |
| 1554 | free_irq(ndev->irq, ks); | 1564 | err_id: |
| 1555 | |||
| 1556 | err_irq: | ||
| 1557 | if (gpio_is_valid(gpio)) | 1565 | if (gpio_is_valid(gpio)) |
| 1558 | gpio_set_value(gpio, 0); | 1566 | gpio_set_value(gpio, 0); |
| 1559 | err_id: | ||
| 1560 | regulator_disable(ks->vdd_reg); | 1567 | regulator_disable(ks->vdd_reg); |
| 1561 | err_reg: | 1568 | err_reg: |
| 1562 | regulator_disable(ks->vdd_io); | 1569 | regulator_disable(ks->vdd_io); |
| @@ -1574,7 +1581,6 @@ static int ks8851_remove(struct spi_device *spi) | |||
| 1574 | dev_info(&spi->dev, "remove\n"); | 1581 | dev_info(&spi->dev, "remove\n"); |
| 1575 | 1582 | ||
| 1576 | unregister_netdev(priv->netdev); | 1583 | unregister_netdev(priv->netdev); |
| 1577 | free_irq(spi->irq, priv); | ||
| 1578 | if (gpio_is_valid(priv->gpio)) | 1584 | if (gpio_is_valid(priv->gpio)) |
| 1579 | gpio_set_value(priv->gpio, 0); | 1585 | gpio_set_value(priv->gpio, 0); |
| 1580 | regulator_disable(priv->vdd_reg); | 1586 | regulator_disable(priv->vdd_reg); |
diff --git a/drivers/net/ethernet/micrel/ks8851.h b/drivers/net/ethernet/micrel/ks8851.h index 852256ef1f22..23da1e3ee429 100644 --- a/drivers/net/ethernet/micrel/ks8851.h +++ b/drivers/net/ethernet/micrel/ks8851.h | |||
| @@ -11,9 +11,15 @@ | |||
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #define KS_CCR 0x08 | 13 | #define KS_CCR 0x08 |
| 14 | #define CCR_LE (1 << 10) /* KSZ8851-16MLL */ | ||
| 14 | #define CCR_EEPROM (1 << 9) | 15 | #define CCR_EEPROM (1 << 9) |
| 15 | #define CCR_SPI (1 << 8) | 16 | #define CCR_SPI (1 << 8) /* KSZ8851SNL */ |
| 16 | #define CCR_32PIN (1 << 0) | 17 | #define CCR_8BIT (1 << 7) /* KSZ8851-16MLL */ |
| 18 | #define CCR_16BIT (1 << 6) /* KSZ8851-16MLL */ | ||
| 19 | #define CCR_32BIT (1 << 5) /* KSZ8851-16MLL */ | ||
| 20 | #define CCR_SHARED (1 << 4) /* KSZ8851-16MLL */ | ||
| 21 | #define CCR_48PIN (1 << 1) /* KSZ8851-16MLL */ | ||
| 22 | #define CCR_32PIN (1 << 0) /* KSZ8851SNL */ | ||
| 17 | 23 | ||
| 18 | /* MAC address registers */ | 24 | /* MAC address registers */ |
| 19 | #define KS_MAR(_m) (0x15 - (_m)) | 25 | #define KS_MAR(_m) (0x15 - (_m)) |
| @@ -112,13 +118,13 @@ | |||
| 112 | #define RXCR1_RXE (1 << 0) | 118 | #define RXCR1_RXE (1 << 0) |
| 113 | 119 | ||
| 114 | #define KS_RXCR2 0x76 | 120 | #define KS_RXCR2 0x76 |
| 115 | #define RXCR2_SRDBL_MASK (0x7 << 5) | 121 | #define RXCR2_SRDBL_MASK (0x7 << 5) /* KSZ8851SNL */ |
| 116 | #define RXCR2_SRDBL_SHIFT (5) | 122 | #define RXCR2_SRDBL_SHIFT (5) /* KSZ8851SNL */ |
| 117 | #define RXCR2_SRDBL_4B (0x0 << 5) | 123 | #define RXCR2_SRDBL_4B (0x0 << 5) /* KSZ8851SNL */ |
| 118 | #define RXCR2_SRDBL_8B (0x1 << 5) | 124 | #define RXCR2_SRDBL_8B (0x1 << 5) /* KSZ8851SNL */ |
| 119 | #define RXCR2_SRDBL_16B (0x2 << 5) | 125 | #define RXCR2_SRDBL_16B (0x2 << 5) /* KSZ8851SNL */ |
| 120 | #define RXCR2_SRDBL_32B (0x3 << 5) | 126 | #define RXCR2_SRDBL_32B (0x3 << 5) /* KSZ8851SNL */ |
| 121 | #define RXCR2_SRDBL_FRAME (0x4 << 5) | 127 | #define RXCR2_SRDBL_FRAME (0x4 << 5) /* KSZ8851SNL */ |
| 122 | #define RXCR2_IUFFP (1 << 4) | 128 | #define RXCR2_IUFFP (1 << 4) |
| 123 | #define RXCR2_RXIUFCEZ (1 << 3) | 129 | #define RXCR2_RXIUFCEZ (1 << 3) |
| 124 | #define RXCR2_UDPLFE (1 << 2) | 130 | #define RXCR2_UDPLFE (1 << 2) |
| @@ -143,8 +149,10 @@ | |||
| 143 | #define RXFSHR_RXCE (1 << 0) | 149 | #define RXFSHR_RXCE (1 << 0) |
| 144 | 150 | ||
| 145 | #define KS_RXFHBCR 0x7E | 151 | #define KS_RXFHBCR 0x7E |
| 152 | #define RXFHBCR_CNT_MASK (0xfff << 0) | ||
| 153 | |||
| 146 | #define KS_TXQCR 0x80 | 154 | #define KS_TXQCR 0x80 |
| 147 | #define TXQCR_AETFE (1 << 2) | 155 | #define TXQCR_AETFE (1 << 2) /* KSZ8851SNL */ |
| 148 | #define TXQCR_TXQMAM (1 << 1) | 156 | #define TXQCR_TXQMAM (1 << 1) |
| 149 | #define TXQCR_METFE (1 << 0) | 157 | #define TXQCR_METFE (1 << 0) |
| 150 | 158 | ||
| @@ -167,6 +175,10 @@ | |||
| 167 | 175 | ||
| 168 | #define KS_RXFDPR 0x86 | 176 | #define KS_RXFDPR 0x86 |
| 169 | #define RXFDPR_RXFPAI (1 << 14) | 177 | #define RXFDPR_RXFPAI (1 << 14) |
| 178 | #define RXFDPR_WST (1 << 12) /* KSZ8851-16MLL */ | ||
| 179 | #define RXFDPR_EMS (1 << 11) /* KSZ8851-16MLL */ | ||
| 180 | #define RXFDPR_RXFP_MASK (0x7ff << 0) | ||
| 181 | #define RXFDPR_RXFP_SHIFT (0) | ||
| 170 | 182 | ||
| 171 | #define KS_RXDTTR 0x8C | 183 | #define KS_RXDTTR 0x8C |
| 172 | #define KS_RXDBCTR 0x8E | 184 | #define KS_RXDBCTR 0x8E |
| @@ -184,7 +196,7 @@ | |||
| 184 | #define IRQ_RXMPDI (1 << 4) | 196 | #define IRQ_RXMPDI (1 << 4) |
| 185 | #define IRQ_LDI (1 << 3) | 197 | #define IRQ_LDI (1 << 3) |
| 186 | #define IRQ_EDI (1 << 2) | 198 | #define IRQ_EDI (1 << 2) |
| 187 | #define IRQ_SPIBEI (1 << 1) | 199 | #define IRQ_SPIBEI (1 << 1) /* KSZ8851SNL */ |
| 188 | #define IRQ_DEDI (1 << 0) | 200 | #define IRQ_DEDI (1 << 0) |
| 189 | 201 | ||
| 190 | #define KS_RXFCTR 0x9C | 202 | #define KS_RXFCTR 0x9C |
| @@ -257,42 +269,37 @@ | |||
| 257 | #define KS_P1ANLPR 0xEE | 269 | #define KS_P1ANLPR 0xEE |
| 258 | 270 | ||
| 259 | #define KS_P1SCLMD 0xF4 | 271 | #define KS_P1SCLMD 0xF4 |
| 260 | #define P1SCLMD_LEDOFF (1 << 15) | ||
| 261 | #define P1SCLMD_TXIDS (1 << 14) | ||
| 262 | #define P1SCLMD_RESTARTAN (1 << 13) | ||
| 263 | #define P1SCLMD_DISAUTOMDIX (1 << 10) | ||
| 264 | #define P1SCLMD_FORCEMDIX (1 << 9) | ||
| 265 | #define P1SCLMD_AUTONEGEN (1 << 7) | ||
| 266 | #define P1SCLMD_FORCE100 (1 << 6) | ||
| 267 | #define P1SCLMD_FORCEFDX (1 << 5) | ||
| 268 | #define P1SCLMD_ADV_FLOW (1 << 4) | ||
| 269 | #define P1SCLMD_ADV_100BT_FDX (1 << 3) | ||
| 270 | #define P1SCLMD_ADV_100BT_HDX (1 << 2) | ||
| 271 | #define P1SCLMD_ADV_10BT_FDX (1 << 1) | ||
| 272 | #define P1SCLMD_ADV_10BT_HDX (1 << 0) | ||
| 273 | 272 | ||
| 274 | #define KS_P1CR 0xF6 | 273 | #define KS_P1CR 0xF6 |
| 275 | #define P1CR_HP_MDIX (1 << 15) | 274 | #define P1CR_LEDOFF (1 << 15) |
| 276 | #define P1CR_REV_POL (1 << 13) | 275 | #define P1CR_TXIDS (1 << 14) |
| 277 | #define P1CR_OP_100M (1 << 10) | 276 | #define P1CR_RESTARTAN (1 << 13) |
| 278 | #define P1CR_OP_FDX (1 << 9) | 277 | #define P1CR_DISAUTOMDIX (1 << 10) |
| 279 | #define P1CR_OP_MDI (1 << 7) | 278 | #define P1CR_FORCEMDIX (1 << 9) |
| 280 | #define P1CR_AN_DONE (1 << 6) | 279 | #define P1CR_AUTONEGEN (1 << 7) |
| 281 | #define P1CR_LINK_GOOD (1 << 5) | 280 | #define P1CR_FORCE100 (1 << 6) |
| 282 | #define P1CR_PNTR_FLOW (1 << 4) | 281 | #define P1CR_FORCEFDX (1 << 5) |
| 283 | #define P1CR_PNTR_100BT_FDX (1 << 3) | 282 | #define P1CR_ADV_FLOW (1 << 4) |
| 284 | #define P1CR_PNTR_100BT_HDX (1 << 2) | 283 | #define P1CR_ADV_100BT_FDX (1 << 3) |
| 285 | #define P1CR_PNTR_10BT_FDX (1 << 1) | 284 | #define P1CR_ADV_100BT_HDX (1 << 2) |
| 286 | #define P1CR_PNTR_10BT_HDX (1 << 0) | 285 | #define P1CR_ADV_10BT_FDX (1 << 1) |
| 286 | #define P1CR_ADV_10BT_HDX (1 << 0) | ||
| 287 | |||
| 288 | #define KS_P1SR 0xF8 | ||
| 289 | #define P1SR_HP_MDIX (1 << 15) | ||
| 290 | #define P1SR_REV_POL (1 << 13) | ||
| 291 | #define P1SR_OP_100M (1 << 10) | ||
| 292 | #define P1SR_OP_FDX (1 << 9) | ||
| 293 | #define P1SR_OP_MDI (1 << 7) | ||
| 294 | #define P1SR_AN_DONE (1 << 6) | ||
| 295 | #define P1SR_LINK_GOOD (1 << 5) | ||
| 296 | #define P1SR_PNTR_FLOW (1 << 4) | ||
| 297 | #define P1SR_PNTR_100BT_FDX (1 << 3) | ||
| 298 | #define P1SR_PNTR_100BT_HDX (1 << 2) | ||
| 299 | #define P1SR_PNTR_10BT_FDX (1 << 1) | ||
| 300 | #define P1SR_PNTR_10BT_HDX (1 << 0) | ||
| 287 | 301 | ||
| 288 | /* TX Frame control */ | 302 | /* TX Frame control */ |
| 289 | |||
| 290 | #define TXFR_TXIC (1 << 15) | 303 | #define TXFR_TXIC (1 << 15) |
| 291 | #define TXFR_TXFID_MASK (0x3f << 0) | 304 | #define TXFR_TXFID_MASK (0x3f << 0) |
| 292 | #define TXFR_TXFID_SHIFT (0) | 305 | #define TXFR_TXFID_SHIFT (0) |
| 293 | |||
| 294 | /* SPI frame opcodes */ | ||
| 295 | #define KS_SPIOP_RD (0x00) | ||
| 296 | #define KS_SPIOP_WR (0x40) | ||
| 297 | #define KS_SPIOP_RXFIFO (0x80) | ||
| 298 | #define KS_SPIOP_TXFIFO (0xC0) | ||
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c index 35f8c9ef204d..c946841c0a06 100644 --- a/drivers/net/ethernet/micrel/ks8851_mll.c +++ b/drivers/net/ethernet/micrel/ks8851_mll.c | |||
| @@ -40,6 +40,8 @@ | |||
| 40 | #include <linux/of_device.h> | 40 | #include <linux/of_device.h> |
| 41 | #include <linux/of_net.h> | 41 | #include <linux/of_net.h> |
| 42 | 42 | ||
| 43 | #include "ks8851.h" | ||
| 44 | |||
| 43 | #define DRV_NAME "ks8851_mll" | 45 | #define DRV_NAME "ks8851_mll" |
| 44 | 46 | ||
| 45 | static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 }; | 47 | static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 }; |
| @@ -48,319 +50,10 @@ static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 }; | |||
| 48 | #define TX_BUF_SIZE 2000 | 50 | #define TX_BUF_SIZE 2000 |
| 49 | #define RX_BUF_SIZE 2000 | 51 | #define RX_BUF_SIZE 2000 |
| 50 | 52 | ||
| 51 | #define KS_CCR 0x08 | ||
| 52 | #define CCR_EEPROM (1 << 9) | ||
| 53 | #define CCR_SPI (1 << 8) | ||
| 54 | #define CCR_8BIT (1 << 7) | ||
| 55 | #define CCR_16BIT (1 << 6) | ||
| 56 | #define CCR_32BIT (1 << 5) | ||
| 57 | #define CCR_SHARED (1 << 4) | ||
| 58 | #define CCR_32PIN (1 << 0) | ||
| 59 | |||
| 60 | /* MAC address registers */ | ||
| 61 | #define KS_MARL 0x10 | ||
| 62 | #define KS_MARM 0x12 | ||
| 63 | #define KS_MARH 0x14 | ||
| 64 | |||
| 65 | #define KS_OBCR 0x20 | ||
| 66 | #define OBCR_ODS_16MA (1 << 6) | ||
| 67 | |||
| 68 | #define KS_EEPCR 0x22 | ||
| 69 | #define EEPCR_EESA (1 << 4) | ||
| 70 | #define EEPCR_EESB (1 << 3) | ||
| 71 | #define EEPCR_EEDO (1 << 2) | ||
| 72 | #define EEPCR_EESCK (1 << 1) | ||
| 73 | #define EEPCR_EECS (1 << 0) | ||
| 74 | |||
| 75 | #define KS_MBIR 0x24 | ||
| 76 | #define MBIR_TXMBF (1 << 12) | ||
| 77 | #define MBIR_TXMBFA (1 << 11) | ||
| 78 | #define MBIR_RXMBF (1 << 4) | ||
| 79 | #define MBIR_RXMBFA (1 << 3) | ||
| 80 | |||
| 81 | #define KS_GRR 0x26 | ||
| 82 | #define GRR_QMU (1 << 1) | ||
| 83 | #define GRR_GSR (1 << 0) | ||
| 84 | |||
| 85 | #define KS_WFCR 0x2A | ||
| 86 | #define WFCR_MPRXE (1 << 7) | ||
| 87 | #define WFCR_WF3E (1 << 3) | ||
| 88 | #define WFCR_WF2E (1 << 2) | ||
| 89 | #define WFCR_WF1E (1 << 1) | ||
| 90 | #define WFCR_WF0E (1 << 0) | ||
| 91 | |||
| 92 | #define KS_WF0CRC0 0x30 | ||
| 93 | #define KS_WF0CRC1 0x32 | ||
| 94 | #define KS_WF0BM0 0x34 | ||
| 95 | #define KS_WF0BM1 0x36 | ||
| 96 | #define KS_WF0BM2 0x38 | ||
| 97 | #define KS_WF0BM3 0x3A | ||
| 98 | |||
| 99 | #define KS_WF1CRC0 0x40 | ||
| 100 | #define KS_WF1CRC1 0x42 | ||
| 101 | #define KS_WF1BM0 0x44 | ||
| 102 | #define KS_WF1BM1 0x46 | ||
| 103 | #define KS_WF1BM2 0x48 | ||
| 104 | #define KS_WF1BM3 0x4A | ||
| 105 | |||
| 106 | #define KS_WF2CRC0 0x50 | ||
| 107 | #define KS_WF2CRC1 0x52 | ||
| 108 | #define KS_WF2BM0 0x54 | ||
| 109 | #define KS_WF2BM1 0x56 | ||
| 110 | #define KS_WF2BM2 0x58 | ||
| 111 | #define KS_WF2BM3 0x5A | ||
| 112 | |||
| 113 | #define KS_WF3CRC0 0x60 | ||
| 114 | #define KS_WF3CRC1 0x62 | ||
| 115 | #define KS_WF3BM0 0x64 | ||
| 116 | #define KS_WF3BM1 0x66 | ||
| 117 | #define KS_WF3BM2 0x68 | ||
| 118 | #define KS_WF3BM3 0x6A | ||
| 119 | |||
| 120 | #define KS_TXCR 0x70 | ||
| 121 | #define TXCR_TCGICMP (1 << 8) | ||
| 122 | #define TXCR_TCGUDP (1 << 7) | ||
| 123 | #define TXCR_TCGTCP (1 << 6) | ||
| 124 | #define TXCR_TCGIP (1 << 5) | ||
| 125 | #define TXCR_FTXQ (1 << 4) | ||
| 126 | #define TXCR_TXFCE (1 << 3) | ||
| 127 | #define TXCR_TXPE (1 << 2) | ||
| 128 | #define TXCR_TXCRC (1 << 1) | ||
| 129 | #define TXCR_TXE (1 << 0) | ||
| 130 | |||
| 131 | #define KS_TXSR 0x72 | ||
| 132 | #define TXSR_TXLC (1 << 13) | ||
| 133 | #define TXSR_TXMC (1 << 12) | ||
| 134 | #define TXSR_TXFID_MASK (0x3f << 0) | ||
| 135 | #define TXSR_TXFID_SHIFT (0) | ||
| 136 | #define TXSR_TXFID_GET(_v) (((_v) >> 0) & 0x3f) | ||
| 137 | |||
| 138 | |||
| 139 | #define KS_RXCR1 0x74 | ||
| 140 | #define RXCR1_FRXQ (1 << 15) | ||
| 141 | #define RXCR1_RXUDPFCC (1 << 14) | ||
| 142 | #define RXCR1_RXTCPFCC (1 << 13) | ||
| 143 | #define RXCR1_RXIPFCC (1 << 12) | ||
| 144 | #define RXCR1_RXPAFMA (1 << 11) | ||
| 145 | #define RXCR1_RXFCE (1 << 10) | ||
| 146 | #define RXCR1_RXEFE (1 << 9) | ||
| 147 | #define RXCR1_RXMAFMA (1 << 8) | ||
| 148 | #define RXCR1_RXBE (1 << 7) | ||
| 149 | #define RXCR1_RXME (1 << 6) | ||
| 150 | #define RXCR1_RXUE (1 << 5) | ||
| 151 | #define RXCR1_RXAE (1 << 4) | ||
| 152 | #define RXCR1_RXINVF (1 << 1) | ||
| 153 | #define RXCR1_RXE (1 << 0) | ||
| 154 | #define RXCR1_FILTER_MASK (RXCR1_RXINVF | RXCR1_RXAE | \ | 53 | #define RXCR1_FILTER_MASK (RXCR1_RXINVF | RXCR1_RXAE | \ |
| 155 | RXCR1_RXMAFMA | RXCR1_RXPAFMA) | 54 | RXCR1_RXMAFMA | RXCR1_RXPAFMA) |
| 156 | |||
| 157 | #define KS_RXCR2 0x76 | ||
| 158 | #define RXCR2_SRDBL_MASK (0x7 << 5) | ||
| 159 | #define RXCR2_SRDBL_SHIFT (5) | ||
| 160 | #define RXCR2_SRDBL_4B (0x0 << 5) | ||
| 161 | #define RXCR2_SRDBL_8B (0x1 << 5) | ||
| 162 | #define RXCR2_SRDBL_16B (0x2 << 5) | ||
| 163 | #define RXCR2_SRDBL_32B (0x3 << 5) | ||
| 164 | /* #define RXCR2_SRDBL_FRAME (0x4 << 5) */ | ||
| 165 | #define RXCR2_IUFFP (1 << 4) | ||
| 166 | #define RXCR2_RXIUFCEZ (1 << 3) | ||
| 167 | #define RXCR2_UDPLFE (1 << 2) | ||
| 168 | #define RXCR2_RXICMPFCC (1 << 1) | ||
| 169 | #define RXCR2_RXSAF (1 << 0) | ||
| 170 | |||
| 171 | #define KS_TXMIR 0x78 | ||
| 172 | |||
| 173 | #define KS_RXFHSR 0x7C | ||
| 174 | #define RXFSHR_RXFV (1 << 15) | ||
| 175 | #define RXFSHR_RXICMPFCS (1 << 13) | ||
| 176 | #define RXFSHR_RXIPFCS (1 << 12) | ||
| 177 | #define RXFSHR_RXTCPFCS (1 << 11) | ||
| 178 | #define RXFSHR_RXUDPFCS (1 << 10) | ||
| 179 | #define RXFSHR_RXBF (1 << 7) | ||
| 180 | #define RXFSHR_RXMF (1 << 6) | ||
| 181 | #define RXFSHR_RXUF (1 << 5) | ||
| 182 | #define RXFSHR_RXMR (1 << 4) | ||
| 183 | #define RXFSHR_RXFT (1 << 3) | ||
| 184 | #define RXFSHR_RXFTL (1 << 2) | ||
| 185 | #define RXFSHR_RXRF (1 << 1) | ||
| 186 | #define RXFSHR_RXCE (1 << 0) | ||
| 187 | #define RXFSHR_ERR (RXFSHR_RXCE | RXFSHR_RXRF |\ | ||
| 188 | RXFSHR_RXFTL | RXFSHR_RXMR |\ | ||
| 189 | RXFSHR_RXICMPFCS | RXFSHR_RXIPFCS |\ | ||
| 190 | RXFSHR_RXTCPFCS) | ||
| 191 | #define KS_RXFHBCR 0x7E | ||
| 192 | #define RXFHBCR_CNT_MASK 0x0FFF | ||
| 193 | |||
| 194 | #define KS_TXQCR 0x80 | ||
| 195 | #define TXQCR_AETFE (1 << 2) | ||
| 196 | #define TXQCR_TXQMAM (1 << 1) | ||
| 197 | #define TXQCR_METFE (1 << 0) | ||
| 198 | |||
| 199 | #define KS_RXQCR 0x82 | ||
| 200 | #define RXQCR_RXDTTS (1 << 12) | ||
| 201 | #define RXQCR_RXDBCTS (1 << 11) | ||
| 202 | #define RXQCR_RXFCTS (1 << 10) | ||
| 203 | #define RXQCR_RXIPHTOE (1 << 9) | ||
| 204 | #define RXQCR_RXDTTE (1 << 7) | ||
| 205 | #define RXQCR_RXDBCTE (1 << 6) | ||
| 206 | #define RXQCR_RXFCTE (1 << 5) | ||
| 207 | #define RXQCR_ADRFE (1 << 4) | ||
| 208 | #define RXQCR_SDA (1 << 3) | ||
| 209 | #define RXQCR_RRXEF (1 << 0) | ||
| 210 | #define RXQCR_CMD_CNTL (RXQCR_RXFCTE|RXQCR_ADRFE) | 55 | #define RXQCR_CMD_CNTL (RXQCR_RXFCTE|RXQCR_ADRFE) |
| 211 | 56 | ||
| 212 | #define KS_TXFDPR 0x84 | ||
| 213 | #define TXFDPR_TXFPAI (1 << 14) | ||
| 214 | #define TXFDPR_TXFP_MASK (0x7ff << 0) | ||
| 215 | #define TXFDPR_TXFP_SHIFT (0) | ||
| 216 | |||
| 217 | #define KS_RXFDPR 0x86 | ||
| 218 | #define RXFDPR_RXFPAI (1 << 14) | ||
| 219 | |||
| 220 | #define KS_RXDTTR 0x8C | ||
| 221 | #define KS_RXDBCTR 0x8E | ||
| 222 | |||
| 223 | #define KS_IER 0x90 | ||
| 224 | #define KS_ISR 0x92 | ||
| 225 | #define IRQ_LCI (1 << 15) | ||
| 226 | #define IRQ_TXI (1 << 14) | ||
| 227 | #define IRQ_RXI (1 << 13) | ||
| 228 | #define IRQ_RXOI (1 << 11) | ||
| 229 | #define IRQ_TXPSI (1 << 9) | ||
| 230 | #define IRQ_RXPSI (1 << 8) | ||
| 231 | #define IRQ_TXSAI (1 << 6) | ||
| 232 | #define IRQ_RXWFDI (1 << 5) | ||
| 233 | #define IRQ_RXMPDI (1 << 4) | ||
| 234 | #define IRQ_LDI (1 << 3) | ||
| 235 | #define IRQ_EDI (1 << 2) | ||
| 236 | #define IRQ_SPIBEI (1 << 1) | ||
| 237 | #define IRQ_DEDI (1 << 0) | ||
| 238 | |||
| 239 | #define KS_RXFCTR 0x9C | ||
| 240 | #define RXFCTR_THRESHOLD_MASK 0x00FF | ||
| 241 | |||
| 242 | #define KS_RXFC 0x9D | ||
| 243 | #define RXFCTR_RXFC_MASK (0xff << 8) | ||
| 244 | #define RXFCTR_RXFC_SHIFT (8) | ||
| 245 | #define RXFCTR_RXFC_GET(_v) (((_v) >> 8) & 0xff) | ||
| 246 | #define RXFCTR_RXFCT_MASK (0xff << 0) | ||
| 247 | #define RXFCTR_RXFCT_SHIFT (0) | ||
| 248 | |||
| 249 | #define KS_TXNTFSR 0x9E | ||
| 250 | |||
| 251 | #define KS_MAHTR0 0xA0 | ||
| 252 | #define KS_MAHTR1 0xA2 | ||
| 253 | #define KS_MAHTR2 0xA4 | ||
| 254 | #define KS_MAHTR3 0xA6 | ||
| 255 | |||
| 256 | #define KS_FCLWR 0xB0 | ||
| 257 | #define KS_FCHWR 0xB2 | ||
| 258 | #define KS_FCOWR 0xB4 | ||
| 259 | |||
| 260 | #define KS_CIDER 0xC0 | ||
| 261 | #define CIDER_ID 0x8870 | ||
| 262 | #define CIDER_REV_MASK (0x7 << 1) | ||
| 263 | #define CIDER_REV_SHIFT (1) | ||
| 264 | #define CIDER_REV_GET(_v) (((_v) >> 1) & 0x7) | ||
| 265 | |||
| 266 | #define KS_CGCR 0xC6 | ||
| 267 | #define KS_IACR 0xC8 | ||
| 268 | #define IACR_RDEN (1 << 12) | ||
| 269 | #define IACR_TSEL_MASK (0x3 << 10) | ||
| 270 | #define IACR_TSEL_SHIFT (10) | ||
| 271 | #define IACR_TSEL_MIB (0x3 << 10) | ||
| 272 | #define IACR_ADDR_MASK (0x1f << 0) | ||
| 273 | #define IACR_ADDR_SHIFT (0) | ||
| 274 | |||
| 275 | #define KS_IADLR 0xD0 | ||
| 276 | #define KS_IAHDR 0xD2 | ||
| 277 | |||
| 278 | #define KS_PMECR 0xD4 | ||
| 279 | #define PMECR_PME_DELAY (1 << 14) | ||
| 280 | #define PMECR_PME_POL (1 << 12) | ||
| 281 | #define PMECR_WOL_WAKEUP (1 << 11) | ||
| 282 | #define PMECR_WOL_MAGICPKT (1 << 10) | ||
| 283 | #define PMECR_WOL_LINKUP (1 << 9) | ||
| 284 | #define PMECR_WOL_ENERGY (1 << 8) | ||
| 285 | #define PMECR_AUTO_WAKE_EN (1 << 7) | ||
| 286 | #define PMECR_WAKEUP_NORMAL (1 << 6) | ||
| 287 | #define PMECR_WKEVT_MASK (0xf << 2) | ||
| 288 | #define PMECR_WKEVT_SHIFT (2) | ||
| 289 | #define PMECR_WKEVT_GET(_v) (((_v) >> 2) & 0xf) | ||
| 290 | #define PMECR_WKEVT_ENERGY (0x1 << 2) | ||
| 291 | #define PMECR_WKEVT_LINK (0x2 << 2) | ||
| 292 | #define PMECR_WKEVT_MAGICPKT (0x4 << 2) | ||
| 293 | #define PMECR_WKEVT_FRAME (0x8 << 2) | ||
| 294 | #define PMECR_PM_MASK (0x3 << 0) | ||
| 295 | #define PMECR_PM_SHIFT (0) | ||
| 296 | #define PMECR_PM_NORMAL (0x0 << 0) | ||
| 297 | #define PMECR_PM_ENERGY (0x1 << 0) | ||
| 298 | #define PMECR_PM_SOFTDOWN (0x2 << 0) | ||
| 299 | #define PMECR_PM_POWERSAVE (0x3 << 0) | ||
| 300 | |||
| 301 | /* Standard MII PHY data */ | ||
| 302 | #define KS_P1MBCR 0xE4 | ||
| 303 | #define P1MBCR_FORCE_FDX (1 << 8) | ||
| 304 | |||
| 305 | #define KS_P1MBSR 0xE6 | ||
| 306 | #define P1MBSR_AN_COMPLETE (1 << 5) | ||
| 307 | #define P1MBSR_AN_CAPABLE (1 << 3) | ||
| 308 | #define P1MBSR_LINK_UP (1 << 2) | ||
| 309 | |||
| 310 | #define KS_PHY1ILR 0xE8 | ||
| 311 | #define KS_PHY1IHR 0xEA | ||
| 312 | #define KS_P1ANAR 0xEC | ||
| 313 | #define KS_P1ANLPR 0xEE | ||
| 314 | |||
| 315 | #define KS_P1SCLMD 0xF4 | ||
| 316 | #define P1SCLMD_LEDOFF (1 << 15) | ||
| 317 | #define P1SCLMD_TXIDS (1 << 14) | ||
| 318 | #define P1SCLMD_RESTARTAN (1 << 13) | ||
| 319 | #define P1SCLMD_DISAUTOMDIX (1 << 10) | ||
| 320 | #define P1SCLMD_FORCEMDIX (1 << 9) | ||
| 321 | #define P1SCLMD_AUTONEGEN (1 << 7) | ||
| 322 | #define P1SCLMD_FORCE100 (1 << 6) | ||
| 323 | #define P1SCLMD_FORCEFDX (1 << 5) | ||
| 324 | #define P1SCLMD_ADV_FLOW (1 << 4) | ||
| 325 | #define P1SCLMD_ADV_100BT_FDX (1 << 3) | ||
| 326 | #define P1SCLMD_ADV_100BT_HDX (1 << 2) | ||
| 327 | #define P1SCLMD_ADV_10BT_FDX (1 << 1) | ||
| 328 | #define P1SCLMD_ADV_10BT_HDX (1 << 0) | ||
| 329 | |||
| 330 | #define KS_P1CR 0xF6 | ||
| 331 | #define P1CR_HP_MDIX (1 << 15) | ||
| 332 | #define P1CR_REV_POL (1 << 13) | ||
| 333 | #define P1CR_OP_100M (1 << 10) | ||
| 334 | #define P1CR_OP_FDX (1 << 9) | ||
| 335 | #define P1CR_OP_MDI (1 << 7) | ||
| 336 | #define P1CR_AN_DONE (1 << 6) | ||
| 337 | #define P1CR_LINK_GOOD (1 << 5) | ||
| 338 | #define P1CR_PNTR_FLOW (1 << 4) | ||
| 339 | #define P1CR_PNTR_100BT_FDX (1 << 3) | ||
| 340 | #define P1CR_PNTR_100BT_HDX (1 << 2) | ||
| 341 | #define P1CR_PNTR_10BT_FDX (1 << 1) | ||
| 342 | #define P1CR_PNTR_10BT_HDX (1 << 0) | ||
| 343 | |||
| 344 | /* TX Frame control */ | ||
| 345 | |||
| 346 | #define TXFR_TXIC (1 << 15) | ||
| 347 | #define TXFR_TXFID_MASK (0x3f << 0) | ||
| 348 | #define TXFR_TXFID_SHIFT (0) | ||
| 349 | |||
| 350 | #define KS_P1SR 0xF8 | ||
| 351 | #define P1SR_HP_MDIX (1 << 15) | ||
| 352 | #define P1SR_REV_POL (1 << 13) | ||
| 353 | #define P1SR_OP_100M (1 << 10) | ||
| 354 | #define P1SR_OP_FDX (1 << 9) | ||
| 355 | #define P1SR_OP_MDI (1 << 7) | ||
| 356 | #define P1SR_AN_DONE (1 << 6) | ||
| 357 | #define P1SR_LINK_GOOD (1 << 5) | ||
| 358 | #define P1SR_PNTR_FLOW (1 << 4) | ||
| 359 | #define P1SR_PNTR_100BT_FDX (1 << 3) | ||
| 360 | #define P1SR_PNTR_100BT_HDX (1 << 2) | ||
| 361 | #define P1SR_PNTR_10BT_FDX (1 << 1) | ||
| 362 | #define P1SR_PNTR_10BT_HDX (1 << 0) | ||
| 363 | |||
| 364 | #define ENUM_BUS_NONE 0 | 57 | #define ENUM_BUS_NONE 0 |
| 365 | #define ENUM_BUS_8BIT 1 | 58 | #define ENUM_BUS_8BIT 1 |
| 366 | #define ENUM_BUS_16BIT 2 | 59 | #define ENUM_BUS_16BIT 2 |
| @@ -1475,7 +1168,7 @@ static void ks_setup(struct ks_net *ks) | |||
| 1475 | ks_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI); | 1168 | ks_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI); |
| 1476 | 1169 | ||
| 1477 | /* Setup Receive Frame Threshold - 1 frame (RXFCTFC) */ | 1170 | /* Setup Receive Frame Threshold - 1 frame (RXFCTFC) */ |
| 1478 | ks_wrreg16(ks, KS_RXFCTR, 1 & RXFCTR_THRESHOLD_MASK); | 1171 | ks_wrreg16(ks, KS_RXFCTR, 1 & RXFCTR_RXFCT_MASK); |
| 1479 | 1172 | ||
| 1480 | /* Setup RxQ Command Control (RXQCR) */ | 1173 | /* Setup RxQ Command Control (RXQCR) */ |
| 1481 | ks->rc_rxqcr = RXQCR_CMD_CNTL; | 1174 | ks->rc_rxqcr = RXQCR_CMD_CNTL; |
| @@ -1488,7 +1181,7 @@ static void ks_setup(struct ks_net *ks) | |||
| 1488 | */ | 1181 | */ |
| 1489 | 1182 | ||
| 1490 | w = ks_rdreg16(ks, KS_P1MBCR); | 1183 | w = ks_rdreg16(ks, KS_P1MBCR); |
| 1491 | w &= ~P1MBCR_FORCE_FDX; | 1184 | w &= ~BMCR_FULLDPLX; |
| 1492 | ks_wrreg16(ks, KS_P1MBCR, w); | 1185 | ks_wrreg16(ks, KS_P1MBCR, w); |
| 1493 | 1186 | ||
| 1494 | w = TXCR_TXFCE | TXCR_TXPE | TXCR_TXCRC | TXCR_TCGIP; | 1187 | w = TXCR_TXFCE | TXCR_TXPE | TXCR_TXCRC | TXCR_TCGIP; |
| @@ -1629,7 +1322,7 @@ static int ks8851_probe(struct platform_device *pdev) | |||
| 1629 | ks_setup_int(ks); | 1322 | ks_setup_int(ks); |
| 1630 | 1323 | ||
| 1631 | data = ks_rdreg16(ks, KS_OBCR); | 1324 | data = ks_rdreg16(ks, KS_OBCR); |
| 1632 | ks_wrreg16(ks, KS_OBCR, data | OBCR_ODS_16MA); | 1325 | ks_wrreg16(ks, KS_OBCR, data | OBCR_ODS_16mA); |
| 1633 | 1326 | ||
| 1634 | /* overwriting the default MAC address */ | 1327 | /* overwriting the default MAC address */ |
| 1635 | if (pdev->dev.of_node) { | 1328 | if (pdev->dev.of_node) { |
diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index eeda4ed98333..e336f6ee94f5 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c | |||
| @@ -48,8 +48,7 @@ nfp_fl_push_vlan(struct nfp_fl_push_vlan *push_vlan, | |||
| 48 | 48 | ||
| 49 | tmp_push_vlan_tci = | 49 | tmp_push_vlan_tci = |
| 50 | FIELD_PREP(NFP_FL_PUSH_VLAN_PRIO, act->vlan.prio) | | 50 | FIELD_PREP(NFP_FL_PUSH_VLAN_PRIO, act->vlan.prio) | |
| 51 | FIELD_PREP(NFP_FL_PUSH_VLAN_VID, act->vlan.vid) | | 51 | FIELD_PREP(NFP_FL_PUSH_VLAN_VID, act->vlan.vid); |
| 52 | NFP_FL_PUSH_VLAN_CFI; | ||
| 53 | push_vlan->vlan_tci = cpu_to_be16(tmp_push_vlan_tci); | 52 | push_vlan->vlan_tci = cpu_to_be16(tmp_push_vlan_tci); |
| 54 | } | 53 | } |
| 55 | 54 | ||
diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h index 4fcaf11ed56e..0ed51e79db00 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | #define NFP_FLOWER_LAYER2_GENEVE_OP BIT(6) | 26 | #define NFP_FLOWER_LAYER2_GENEVE_OP BIT(6) |
| 27 | 27 | ||
| 28 | #define NFP_FLOWER_MASK_VLAN_PRIO GENMASK(15, 13) | 28 | #define NFP_FLOWER_MASK_VLAN_PRIO GENMASK(15, 13) |
| 29 | #define NFP_FLOWER_MASK_VLAN_CFI BIT(12) | 29 | #define NFP_FLOWER_MASK_VLAN_PRESENT BIT(12) |
| 30 | #define NFP_FLOWER_MASK_VLAN_VID GENMASK(11, 0) | 30 | #define NFP_FLOWER_MASK_VLAN_VID GENMASK(11, 0) |
| 31 | 31 | ||
| 32 | #define NFP_FLOWER_MASK_MPLS_LB GENMASK(31, 12) | 32 | #define NFP_FLOWER_MASK_MPLS_LB GENMASK(31, 12) |
| @@ -82,7 +82,6 @@ | |||
| 82 | #define NFP_FL_OUT_FLAGS_TYPE_IDX GENMASK(2, 0) | 82 | #define NFP_FL_OUT_FLAGS_TYPE_IDX GENMASK(2, 0) |
| 83 | 83 | ||
| 84 | #define NFP_FL_PUSH_VLAN_PRIO GENMASK(15, 13) | 84 | #define NFP_FL_PUSH_VLAN_PRIO GENMASK(15, 13) |
| 85 | #define NFP_FL_PUSH_VLAN_CFI BIT(12) | ||
| 86 | #define NFP_FL_PUSH_VLAN_VID GENMASK(11, 0) | 85 | #define NFP_FL_PUSH_VLAN_VID GENMASK(11, 0) |
| 87 | 86 | ||
| 88 | #define IPV6_FLOW_LABEL_MASK cpu_to_be32(0x000fffff) | 87 | #define IPV6_FLOW_LABEL_MASK cpu_to_be32(0x000fffff) |
diff --git a/drivers/net/ethernet/netronome/nfp/flower/match.c b/drivers/net/ethernet/netronome/nfp/flower/match.c index e03c8ef2c28c..9b8b843d0340 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/match.c +++ b/drivers/net/ethernet/netronome/nfp/flower/match.c | |||
| @@ -30,20 +30,19 @@ nfp_flower_compile_meta_tci(struct nfp_flower_meta_tci *ext, | |||
| 30 | 30 | ||
| 31 | flow_rule_match_vlan(rule, &match); | 31 | flow_rule_match_vlan(rule, &match); |
| 32 | /* Populate the tci field. */ | 32 | /* Populate the tci field. */ |
| 33 | if (match.key->vlan_id || match.key->vlan_priority) { | 33 | tmp_tci = NFP_FLOWER_MASK_VLAN_PRESENT; |
| 34 | tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, | 34 | tmp_tci |= FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, |
| 35 | match.key->vlan_priority) | | 35 | match.key->vlan_priority) | |
| 36 | FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, | 36 | FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, |
| 37 | match.key->vlan_id) | | 37 | match.key->vlan_id); |
| 38 | NFP_FLOWER_MASK_VLAN_CFI; | 38 | ext->tci = cpu_to_be16(tmp_tci); |
| 39 | ext->tci = cpu_to_be16(tmp_tci); | 39 | |
| 40 | tmp_tci = FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, | 40 | tmp_tci = NFP_FLOWER_MASK_VLAN_PRESENT; |
| 41 | match.mask->vlan_priority) | | 41 | tmp_tci |= FIELD_PREP(NFP_FLOWER_MASK_VLAN_PRIO, |
| 42 | FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, | 42 | match.mask->vlan_priority) | |
| 43 | match.mask->vlan_id) | | 43 | FIELD_PREP(NFP_FLOWER_MASK_VLAN_VID, |
| 44 | NFP_FLOWER_MASK_VLAN_CFI; | 44 | match.mask->vlan_id); |
| 45 | msk->tci = cpu_to_be16(tmp_tci); | 45 | msk->tci = cpu_to_be16(tmp_tci); |
| 46 | } | ||
| 47 | } | 46 | } |
| 48 | } | 47 | } |
| 49 | 48 | ||
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index d2c803bb4e56..94d228c04496 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c | |||
| @@ -195,7 +195,7 @@ static netdev_tx_t nfp_repr_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
| 195 | ret = dev_queue_xmit(skb); | 195 | ret = dev_queue_xmit(skb); |
| 196 | nfp_repr_inc_tx_stats(netdev, len, ret); | 196 | nfp_repr_inc_tx_stats(netdev, len, ret); |
| 197 | 197 | ||
| 198 | return ret; | 198 | return NETDEV_TX_OK; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | static int nfp_repr_stop(struct net_device *netdev) | 201 | static int nfp_repr_stop(struct net_device *netdev) |
| @@ -383,7 +383,7 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev, | |||
| 383 | netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); | 383 | netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); |
| 384 | netdev->gso_max_segs = NFP_NET_LSO_MAX_SEGS; | 384 | netdev->gso_max_segs = NFP_NET_LSO_MAX_SEGS; |
| 385 | 385 | ||
| 386 | netdev->priv_flags |= IFF_NO_QUEUE; | 386 | netdev->priv_flags |= IFF_NO_QUEUE | IFF_DISABLE_NETPOLL; |
| 387 | netdev->features |= NETIF_F_LLTX; | 387 | netdev->features |= NETIF_F_LLTX; |
| 388 | 388 | ||
| 389 | if (nfp_app_has_tc(app)) { | 389 | if (nfp_app_has_tc(app)) { |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h index 0c443ea98479..374a4d4371f9 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | |||
| @@ -497,7 +497,7 @@ struct qlcnic_hardware_context { | |||
| 497 | u16 board_type; | 497 | u16 board_type; |
| 498 | u16 supported_type; | 498 | u16 supported_type; |
| 499 | 499 | ||
| 500 | u16 link_speed; | 500 | u32 link_speed; |
| 501 | u16 link_duplex; | 501 | u16 link_duplex; |
| 502 | u16 link_autoneg; | 502 | u16 link_autoneg; |
| 503 | u16 module_type; | 503 | u16 module_type; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index 3b0adda7cc9c..a4cd6f2cfb86 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | |||
| @@ -1048,6 +1048,8 @@ int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode) | |||
| 1048 | 1048 | ||
| 1049 | for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { | 1049 | for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { |
| 1050 | skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE); | 1050 | skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE); |
| 1051 | if (!skb) | ||
| 1052 | break; | ||
| 1051 | qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); | 1053 | qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); |
| 1052 | skb_put(skb, QLCNIC_ILB_PKT_SIZE); | 1054 | skb_put(skb, QLCNIC_ILB_PKT_SIZE); |
| 1053 | adapter->ahw->diag_cnt = 0; | 1055 | adapter->ahw->diag_cnt = 0; |
diff --git a/drivers/net/ethernet/realtek/atp.c b/drivers/net/ethernet/realtek/atp.c index cfb67b746595..58e0ca9093d3 100644 --- a/drivers/net/ethernet/realtek/atp.c +++ b/drivers/net/ethernet/realtek/atp.c | |||
| @@ -482,7 +482,7 @@ static void hardware_init(struct net_device *dev) | |||
| 482 | write_reg_high(ioaddr, IMR, ISRh_RxErr); | 482 | write_reg_high(ioaddr, IMR, ISRh_RxErr); |
| 483 | 483 | ||
| 484 | lp->tx_unit_busy = 0; | 484 | lp->tx_unit_busy = 0; |
| 485 | lp->pac_cnt_in_tx_buf = 0; | 485 | lp->pac_cnt_in_tx_buf = 0; |
| 486 | lp->saved_tx_size = 0; | 486 | lp->saved_tx_size = 0; |
| 487 | } | 487 | } |
| 488 | 488 | ||
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index c29dde064078..ed651dde6ef9 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/pm_runtime.h> | 28 | #include <linux/pm_runtime.h> |
| 29 | #include <linux/firmware.h> | 29 | #include <linux/firmware.h> |
| 30 | #include <linux/prefetch.h> | 30 | #include <linux/prefetch.h> |
| 31 | #include <linux/pci-aspm.h> | ||
| 31 | #include <linux/ipv6.h> | 32 | #include <linux/ipv6.h> |
| 32 | #include <net/ip6_checksum.h> | 33 | #include <net/ip6_checksum.h> |
| 33 | 34 | ||
| @@ -678,6 +679,7 @@ struct rtl8169_private { | |||
| 678 | struct work_struct work; | 679 | struct work_struct work; |
| 679 | } wk; | 680 | } wk; |
| 680 | 681 | ||
| 682 | unsigned irq_enabled:1; | ||
| 681 | unsigned supports_gmii:1; | 683 | unsigned supports_gmii:1; |
| 682 | dma_addr_t counters_phys_addr; | 684 | dma_addr_t counters_phys_addr; |
| 683 | struct rtl8169_counters *counters; | 685 | struct rtl8169_counters *counters; |
| @@ -1293,6 +1295,7 @@ static void rtl_ack_events(struct rtl8169_private *tp, u16 bits) | |||
| 1293 | static void rtl_irq_disable(struct rtl8169_private *tp) | 1295 | static void rtl_irq_disable(struct rtl8169_private *tp) |
| 1294 | { | 1296 | { |
| 1295 | RTL_W16(tp, IntrMask, 0); | 1297 | RTL_W16(tp, IntrMask, 0); |
| 1298 | tp->irq_enabled = 0; | ||
| 1296 | } | 1299 | } |
| 1297 | 1300 | ||
| 1298 | #define RTL_EVENT_NAPI_RX (RxOK | RxErr) | 1301 | #define RTL_EVENT_NAPI_RX (RxOK | RxErr) |
| @@ -1301,6 +1304,7 @@ static void rtl_irq_disable(struct rtl8169_private *tp) | |||
| 1301 | 1304 | ||
| 1302 | static void rtl_irq_enable(struct rtl8169_private *tp) | 1305 | static void rtl_irq_enable(struct rtl8169_private *tp) |
| 1303 | { | 1306 | { |
| 1307 | tp->irq_enabled = 1; | ||
| 1304 | RTL_W16(tp, IntrMask, tp->irq_mask); | 1308 | RTL_W16(tp, IntrMask, tp->irq_mask); |
| 1305 | } | 1309 | } |
| 1306 | 1310 | ||
| @@ -5457,7 +5461,7 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp) | |||
| 5457 | tp->cp_cmd |= PktCntrDisable | INTT_1; | 5461 | tp->cp_cmd |= PktCntrDisable | INTT_1; |
| 5458 | RTL_W16(tp, CPlusCmd, tp->cp_cmd); | 5462 | RTL_W16(tp, CPlusCmd, tp->cp_cmd); |
| 5459 | 5463 | ||
| 5460 | RTL_W16(tp, IntrMitigate, 0x5151); | 5464 | RTL_W16(tp, IntrMitigate, 0x5100); |
| 5461 | 5465 | ||
| 5462 | /* Work around for RxFIFO overflow. */ | 5466 | /* Work around for RxFIFO overflow. */ |
| 5463 | if (tp->mac_version == RTL_GIGA_MAC_VER_11) { | 5467 | if (tp->mac_version == RTL_GIGA_MAC_VER_11) { |
| @@ -6520,9 +6524,8 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) | |||
| 6520 | { | 6524 | { |
| 6521 | struct rtl8169_private *tp = dev_instance; | 6525 | struct rtl8169_private *tp = dev_instance; |
| 6522 | u16 status = RTL_R16(tp, IntrStatus); | 6526 | u16 status = RTL_R16(tp, IntrStatus); |
| 6523 | u16 irq_mask = RTL_R16(tp, IntrMask); | ||
| 6524 | 6527 | ||
| 6525 | if (status == 0xffff || !(status & irq_mask)) | 6528 | if (!tp->irq_enabled || status == 0xffff || !(status & tp->irq_mask)) |
| 6526 | return IRQ_NONE; | 6529 | return IRQ_NONE; |
| 6527 | 6530 | ||
| 6528 | if (unlikely(status & SYSErr)) { | 6531 | if (unlikely(status & SYSErr)) { |
| @@ -6540,7 +6543,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) | |||
| 6540 | set_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags); | 6543 | set_bit(RTL_FLAG_TASK_RESET_PENDING, tp->wk.flags); |
| 6541 | } | 6544 | } |
| 6542 | 6545 | ||
| 6543 | if (status & RTL_EVENT_NAPI) { | 6546 | if (status & (RTL_EVENT_NAPI | LinkChg)) { |
| 6544 | rtl_irq_disable(tp); | 6547 | rtl_irq_disable(tp); |
| 6545 | napi_schedule_irqoff(&tp->napi); | 6548 | napi_schedule_irqoff(&tp->napi); |
| 6546 | } | 6549 | } |
| @@ -7350,6 +7353,11 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 7350 | if (rc) | 7353 | if (rc) |
| 7351 | return rc; | 7354 | return rc; |
| 7352 | 7355 | ||
| 7356 | /* Disable ASPM completely as that cause random device stop working | ||
| 7357 | * problems as well as full system hangs for some PCIe devices users. | ||
| 7358 | */ | ||
| 7359 | pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); | ||
| 7360 | |||
| 7353 | /* enable device (incl. PCI PM wakeup and hotplug setup) */ | 7361 | /* enable device (incl. PCI PM wakeup and hotplug setup) */ |
| 7354 | rc = pcim_enable_device(pdev); | 7362 | rc = pcim_enable_device(pdev); |
| 7355 | if (rc < 0) { | 7363 | if (rc < 0) { |
diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c index 6073387511f8..67f9bb6e941b 100644 --- a/drivers/net/ethernet/sis/sis900.c +++ b/drivers/net/ethernet/sis/sis900.c | |||
| @@ -730,10 +730,10 @@ static u16 sis900_default_phy(struct net_device * net_dev) | |||
| 730 | status = mdio_read(net_dev, phy->phy_addr, MII_STATUS); | 730 | status = mdio_read(net_dev, phy->phy_addr, MII_STATUS); |
| 731 | 731 | ||
| 732 | /* Link ON & Not select default PHY & not ghost PHY */ | 732 | /* Link ON & Not select default PHY & not ghost PHY */ |
| 733 | if ((status & MII_STAT_LINK) && !default_phy && | 733 | if ((status & MII_STAT_LINK) && !default_phy && |
| 734 | (phy->phy_types != UNKNOWN)) | 734 | (phy->phy_types != UNKNOWN)) { |
| 735 | default_phy = phy; | 735 | default_phy = phy; |
| 736 | else { | 736 | } else { |
| 737 | status = mdio_read(net_dev, phy->phy_addr, MII_CONTROL); | 737 | status = mdio_read(net_dev, phy->phy_addr, MII_CONTROL); |
| 738 | mdio_write(net_dev, phy->phy_addr, MII_CONTROL, | 738 | mdio_write(net_dev, phy->phy_addr, MII_CONTROL, |
| 739 | status | MII_CNTL_AUTO | MII_CNTL_ISOLATE); | 739 | status | MII_CNTL_AUTO | MII_CNTL_ISOLATE); |
| @@ -741,7 +741,7 @@ static u16 sis900_default_phy(struct net_device * net_dev) | |||
| 741 | phy_home = phy; | 741 | phy_home = phy; |
| 742 | else if(phy->phy_types == LAN) | 742 | else if(phy->phy_types == LAN) |
| 743 | phy_lan = phy; | 743 | phy_lan = phy; |
| 744 | } | 744 | } |
| 745 | } | 745 | } |
| 746 | 746 | ||
| 747 | if (!default_phy && phy_home) | 747 | if (!default_phy && phy_home) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/descs_com.h b/drivers/net/ethernet/stmicro/stmmac/descs_com.h index 40d6356a7e73..3dfb07a78952 100644 --- a/drivers/net/ethernet/stmicro/stmmac/descs_com.h +++ b/drivers/net/ethernet/stmicro/stmmac/descs_com.h | |||
| @@ -29,11 +29,13 @@ | |||
| 29 | /* Specific functions used for Ring mode */ | 29 | /* Specific functions used for Ring mode */ |
| 30 | 30 | ||
| 31 | /* Enhanced descriptors */ | 31 | /* Enhanced descriptors */ |
| 32 | static inline void ehn_desc_rx_set_on_ring(struct dma_desc *p, int end) | 32 | static inline void ehn_desc_rx_set_on_ring(struct dma_desc *p, int end, |
| 33 | int bfsize) | ||
| 33 | { | 34 | { |
| 34 | p->des1 |= cpu_to_le32((BUF_SIZE_8KiB | 35 | if (bfsize == BUF_SIZE_16KiB) |
| 35 | << ERDES1_BUFFER2_SIZE_SHIFT) | 36 | p->des1 |= cpu_to_le32((BUF_SIZE_8KiB |
| 36 | & ERDES1_BUFFER2_SIZE_MASK); | 37 | << ERDES1_BUFFER2_SIZE_SHIFT) |
| 38 | & ERDES1_BUFFER2_SIZE_MASK); | ||
| 37 | 39 | ||
| 38 | if (end) | 40 | if (end) |
| 39 | p->des1 |= cpu_to_le32(ERDES1_END_RING); | 41 | p->des1 |= cpu_to_le32(ERDES1_END_RING); |
| @@ -59,11 +61,15 @@ static inline void enh_set_tx_desc_len_on_ring(struct dma_desc *p, int len) | |||
| 59 | } | 61 | } |
| 60 | 62 | ||
| 61 | /* Normal descriptors */ | 63 | /* Normal descriptors */ |
| 62 | static inline void ndesc_rx_set_on_ring(struct dma_desc *p, int end) | 64 | static inline void ndesc_rx_set_on_ring(struct dma_desc *p, int end, int bfsize) |
| 63 | { | 65 | { |
| 64 | p->des1 |= cpu_to_le32(((BUF_SIZE_2KiB - 1) | 66 | if (bfsize >= BUF_SIZE_2KiB) { |
| 65 | << RDES1_BUFFER2_SIZE_SHIFT) | 67 | int bfsize2; |
| 66 | & RDES1_BUFFER2_SIZE_MASK); | 68 | |
| 69 | bfsize2 = min(bfsize - BUF_SIZE_2KiB + 1, BUF_SIZE_2KiB - 1); | ||
| 70 | p->des1 |= cpu_to_le32((bfsize2 << RDES1_BUFFER2_SIZE_SHIFT) | ||
| 71 | & RDES1_BUFFER2_SIZE_MASK); | ||
| 72 | } | ||
| 67 | 73 | ||
| 68 | if (end) | 74 | if (end) |
| 69 | p->des1 |= cpu_to_le32(RDES1_END_RING); | 75 | p->des1 |= cpu_to_le32(RDES1_END_RING); |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c index 7fbb6a4dbf51..e061e9f5fad7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | |||
| @@ -296,7 +296,7 @@ exit: | |||
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | static void dwmac4_rd_init_rx_desc(struct dma_desc *p, int disable_rx_ic, | 298 | static void dwmac4_rd_init_rx_desc(struct dma_desc *p, int disable_rx_ic, |
| 299 | int mode, int end) | 299 | int mode, int end, int bfsize) |
| 300 | { | 300 | { |
| 301 | dwmac4_set_rx_owner(p, disable_rx_ic); | 301 | dwmac4_set_rx_owner(p, disable_rx_ic); |
| 302 | } | 302 | } |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c index 1d858fdec997..98fa471da7c0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | |||
| @@ -123,7 +123,7 @@ static int dwxgmac2_get_rx_timestamp_status(void *desc, void *next_desc, | |||
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | static void dwxgmac2_init_rx_desc(struct dma_desc *p, int disable_rx_ic, | 125 | static void dwxgmac2_init_rx_desc(struct dma_desc *p, int disable_rx_ic, |
| 126 | int mode, int end) | 126 | int mode, int end, int bfsize) |
| 127 | { | 127 | { |
| 128 | dwxgmac2_set_rx_owner(p, disable_rx_ic); | 128 | dwxgmac2_set_rx_owner(p, disable_rx_ic); |
| 129 | } | 129 | } |
diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index 5ef91a790f9d..5202d6ad7919 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c | |||
| @@ -201,6 +201,11 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x, | |||
| 201 | if (unlikely(rdes0 & RDES0_OWN)) | 201 | if (unlikely(rdes0 & RDES0_OWN)) |
| 202 | return dma_own; | 202 | return dma_own; |
| 203 | 203 | ||
| 204 | if (unlikely(!(rdes0 & RDES0_LAST_DESCRIPTOR))) { | ||
| 205 | stats->rx_length_errors++; | ||
| 206 | return discard_frame; | ||
| 207 | } | ||
| 208 | |||
| 204 | if (unlikely(rdes0 & RDES0_ERROR_SUMMARY)) { | 209 | if (unlikely(rdes0 & RDES0_ERROR_SUMMARY)) { |
| 205 | if (unlikely(rdes0 & RDES0_DESCRIPTOR_ERROR)) { | 210 | if (unlikely(rdes0 & RDES0_DESCRIPTOR_ERROR)) { |
| 206 | x->rx_desc++; | 211 | x->rx_desc++; |
| @@ -231,9 +236,10 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x, | |||
| 231 | * It doesn't match with the information reported into the databook. | 236 | * It doesn't match with the information reported into the databook. |
| 232 | * At any rate, we need to understand if the CSUM hw computation is ok | 237 | * At any rate, we need to understand if the CSUM hw computation is ok |
| 233 | * and report this info to the upper layers. */ | 238 | * and report this info to the upper layers. */ |
| 234 | ret = enh_desc_coe_rdes0(!!(rdes0 & RDES0_IPC_CSUM_ERROR), | 239 | if (likely(ret == good_frame)) |
| 235 | !!(rdes0 & RDES0_FRAME_TYPE), | 240 | ret = enh_desc_coe_rdes0(!!(rdes0 & RDES0_IPC_CSUM_ERROR), |
| 236 | !!(rdes0 & ERDES0_RX_MAC_ADDR)); | 241 | !!(rdes0 & RDES0_FRAME_TYPE), |
| 242 | !!(rdes0 & ERDES0_RX_MAC_ADDR)); | ||
| 237 | 243 | ||
| 238 | if (unlikely(rdes0 & RDES0_DRIBBLING)) | 244 | if (unlikely(rdes0 & RDES0_DRIBBLING)) |
| 239 | x->dribbling_bit++; | 245 | x->dribbling_bit++; |
| @@ -259,15 +265,19 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x, | |||
| 259 | } | 265 | } |
| 260 | 266 | ||
| 261 | static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, | 267 | static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, |
| 262 | int mode, int end) | 268 | int mode, int end, int bfsize) |
| 263 | { | 269 | { |
| 270 | int bfsize1; | ||
| 271 | |||
| 264 | p->des0 |= cpu_to_le32(RDES0_OWN); | 272 | p->des0 |= cpu_to_le32(RDES0_OWN); |
| 265 | p->des1 |= cpu_to_le32(BUF_SIZE_8KiB & ERDES1_BUFFER1_SIZE_MASK); | 273 | |
| 274 | bfsize1 = min(bfsize, BUF_SIZE_8KiB); | ||
| 275 | p->des1 |= cpu_to_le32(bfsize1 & ERDES1_BUFFER1_SIZE_MASK); | ||
| 266 | 276 | ||
| 267 | if (mode == STMMAC_CHAIN_MODE) | 277 | if (mode == STMMAC_CHAIN_MODE) |
| 268 | ehn_desc_rx_set_on_chain(p); | 278 | ehn_desc_rx_set_on_chain(p); |
| 269 | else | 279 | else |
| 270 | ehn_desc_rx_set_on_ring(p, end); | 280 | ehn_desc_rx_set_on_ring(p, end, bfsize); |
| 271 | 281 | ||
| 272 | if (disable_rx_ic) | 282 | if (disable_rx_ic) |
| 273 | p->des1 |= cpu_to_le32(ERDES1_DISABLE_IC); | 283 | p->des1 |= cpu_to_le32(ERDES1_DISABLE_IC); |
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 92b8944f26e3..5bb00234d961 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h | |||
| @@ -33,7 +33,7 @@ struct dma_extended_desc; | |||
| 33 | struct stmmac_desc_ops { | 33 | struct stmmac_desc_ops { |
| 34 | /* DMA RX descriptor ring initialization */ | 34 | /* DMA RX descriptor ring initialization */ |
| 35 | void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode, | 35 | void (*init_rx_desc)(struct dma_desc *p, int disable_rx_ic, int mode, |
| 36 | int end); | 36 | int end, int bfsize); |
| 37 | /* DMA TX descriptor ring initialization */ | 37 | /* DMA TX descriptor ring initialization */ |
| 38 | void (*init_tx_desc)(struct dma_desc *p, int mode, int end); | 38 | void (*init_tx_desc)(struct dma_desc *p, int mode, int end); |
| 39 | /* Invoked by the xmit function to prepare the tx descriptor */ | 39 | /* Invoked by the xmit function to prepare the tx descriptor */ |
diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c index de65bb29feba..b7dd4e3c760d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c | |||
| @@ -91,8 +91,6 @@ static int ndesc_get_rx_status(void *data, struct stmmac_extra_stats *x, | |||
| 91 | return dma_own; | 91 | return dma_own; |
| 92 | 92 | ||
| 93 | if (unlikely(!(rdes0 & RDES0_LAST_DESCRIPTOR))) { | 93 | if (unlikely(!(rdes0 & RDES0_LAST_DESCRIPTOR))) { |
| 94 | pr_warn("%s: Oversized frame spanned multiple buffers\n", | ||
| 95 | __func__); | ||
| 96 | stats->rx_length_errors++; | 94 | stats->rx_length_errors++; |
| 97 | return discard_frame; | 95 | return discard_frame; |
| 98 | } | 96 | } |
| @@ -135,15 +133,19 @@ static int ndesc_get_rx_status(void *data, struct stmmac_extra_stats *x, | |||
| 135 | } | 133 | } |
| 136 | 134 | ||
| 137 | static void ndesc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode, | 135 | static void ndesc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode, |
| 138 | int end) | 136 | int end, int bfsize) |
| 139 | { | 137 | { |
| 138 | int bfsize1; | ||
| 139 | |||
| 140 | p->des0 |= cpu_to_le32(RDES0_OWN); | 140 | p->des0 |= cpu_to_le32(RDES0_OWN); |
| 141 | p->des1 |= cpu_to_le32((BUF_SIZE_2KiB - 1) & RDES1_BUFFER1_SIZE_MASK); | 141 | |
| 142 | bfsize1 = min(bfsize, BUF_SIZE_2KiB - 1); | ||
| 143 | p->des1 |= cpu_to_le32(bfsize & RDES1_BUFFER1_SIZE_MASK); | ||
| 142 | 144 | ||
| 143 | if (mode == STMMAC_CHAIN_MODE) | 145 | if (mode == STMMAC_CHAIN_MODE) |
| 144 | ndesc_rx_set_on_chain(p, end); | 146 | ndesc_rx_set_on_chain(p, end); |
| 145 | else | 147 | else |
| 146 | ndesc_rx_set_on_ring(p, end); | 148 | ndesc_rx_set_on_ring(p, end, bfsize); |
| 147 | 149 | ||
| 148 | if (disable_rx_ic) | 150 | if (disable_rx_ic) |
| 149 | p->des1 |= cpu_to_le32(RDES1_DISABLE_IC); | 151 | p->des1 |= cpu_to_le32(RDES1_DISABLE_IC); |
diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c index d8c5bc412219..4d9bcb4d0378 100644 --- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c | |||
| @@ -59,7 +59,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) | |||
| 59 | 59 | ||
| 60 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); | 60 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); |
| 61 | stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum, | 61 | stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum, |
| 62 | STMMAC_RING_MODE, 1, false, skb->len); | 62 | STMMAC_RING_MODE, 0, false, skb->len); |
| 63 | tx_q->tx_skbuff[entry] = NULL; | 63 | tx_q->tx_skbuff[entry] = NULL; |
| 64 | entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE); | 64 | entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE); |
| 65 | 65 | ||
| @@ -79,7 +79,8 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) | |||
| 79 | 79 | ||
| 80 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); | 80 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); |
| 81 | stmmac_prepare_tx_desc(priv, desc, 0, len, csum, | 81 | stmmac_prepare_tx_desc(priv, desc, 0, len, csum, |
| 82 | STMMAC_RING_MODE, 1, true, skb->len); | 82 | STMMAC_RING_MODE, 1, !skb_is_nonlinear(skb), |
| 83 | skb->len); | ||
| 83 | } else { | 84 | } else { |
| 84 | des2 = dma_map_single(priv->device, skb->data, | 85 | des2 = dma_map_single(priv->device, skb->data, |
| 85 | nopaged_len, DMA_TO_DEVICE); | 86 | nopaged_len, DMA_TO_DEVICE); |
| @@ -91,7 +92,8 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum) | |||
| 91 | tx_q->tx_skbuff_dma[entry].is_jumbo = true; | 92 | tx_q->tx_skbuff_dma[entry].is_jumbo = true; |
| 92 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); | 93 | desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB); |
| 93 | stmmac_prepare_tx_desc(priv, desc, 1, nopaged_len, csum, | 94 | stmmac_prepare_tx_desc(priv, desc, 1, nopaged_len, csum, |
| 94 | STMMAC_RING_MODE, 1, true, skb->len); | 95 | STMMAC_RING_MODE, 0, !skb_is_nonlinear(skb), |
| 96 | skb->len); | ||
| 95 | } | 97 | } |
| 96 | 98 | ||
| 97 | tx_q->cur_tx = entry; | 99 | tx_q->cur_tx = entry; |
| @@ -111,10 +113,11 @@ static unsigned int is_jumbo_frm(int len, int enh_desc) | |||
| 111 | 113 | ||
| 112 | static void refill_desc3(void *priv_ptr, struct dma_desc *p) | 114 | static void refill_desc3(void *priv_ptr, struct dma_desc *p) |
| 113 | { | 115 | { |
| 114 | struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; | 116 | struct stmmac_rx_queue *rx_q = priv_ptr; |
| 117 | struct stmmac_priv *priv = rx_q->priv_data; | ||
| 115 | 118 | ||
| 116 | /* Fill DES3 in case of RING mode */ | 119 | /* Fill DES3 in case of RING mode */ |
| 117 | if (priv->dma_buf_sz >= BUF_SIZE_8KiB) | 120 | if (priv->dma_buf_sz == BUF_SIZE_16KiB) |
| 118 | p->des3 = cpu_to_le32(le32_to_cpu(p->des2) + BUF_SIZE_8KiB); | 121 | p->des3 = cpu_to_le32(le32_to_cpu(p->des2) + BUF_SIZE_8KiB); |
| 119 | } | 122 | } |
| 120 | 123 | ||
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 97c5e1aad88f..a26e36dbb5df 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
| @@ -1136,11 +1136,13 @@ static void stmmac_clear_rx_descriptors(struct stmmac_priv *priv, u32 queue) | |||
| 1136 | if (priv->extend_desc) | 1136 | if (priv->extend_desc) |
| 1137 | stmmac_init_rx_desc(priv, &rx_q->dma_erx[i].basic, | 1137 | stmmac_init_rx_desc(priv, &rx_q->dma_erx[i].basic, |
| 1138 | priv->use_riwt, priv->mode, | 1138 | priv->use_riwt, priv->mode, |
| 1139 | (i == DMA_RX_SIZE - 1)); | 1139 | (i == DMA_RX_SIZE - 1), |
| 1140 | priv->dma_buf_sz); | ||
| 1140 | else | 1141 | else |
| 1141 | stmmac_init_rx_desc(priv, &rx_q->dma_rx[i], | 1142 | stmmac_init_rx_desc(priv, &rx_q->dma_rx[i], |
| 1142 | priv->use_riwt, priv->mode, | 1143 | priv->use_riwt, priv->mode, |
| 1143 | (i == DMA_RX_SIZE - 1)); | 1144 | (i == DMA_RX_SIZE - 1), |
| 1145 | priv->dma_buf_sz); | ||
| 1144 | } | 1146 | } |
| 1145 | 1147 | ||
| 1146 | /** | 1148 | /** |
| @@ -3216,14 +3218,16 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 3216 | stmmac_prepare_tx_desc(priv, first, 1, nopaged_len, | 3218 | stmmac_prepare_tx_desc(priv, first, 1, nopaged_len, |
| 3217 | csum_insertion, priv->mode, 1, last_segment, | 3219 | csum_insertion, priv->mode, 1, last_segment, |
| 3218 | skb->len); | 3220 | skb->len); |
| 3219 | 3221 | } else { | |
| 3220 | /* The own bit must be the latest setting done when prepare the | 3222 | stmmac_set_tx_owner(priv, first); |
| 3221 | * descriptor and then barrier is needed to make sure that | ||
| 3222 | * all is coherent before granting the DMA engine. | ||
| 3223 | */ | ||
| 3224 | wmb(); | ||
| 3225 | } | 3223 | } |
| 3226 | 3224 | ||
| 3225 | /* The own bit must be the latest setting done when prepare the | ||
| 3226 | * descriptor and then barrier is needed to make sure that | ||
| 3227 | * all is coherent before granting the DMA engine. | ||
| 3228 | */ | ||
| 3229 | wmb(); | ||
| 3230 | |||
| 3227 | netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len); | 3231 | netdev_tx_sent_queue(netdev_get_tx_queue(dev, queue), skb->len); |
| 3228 | 3232 | ||
| 3229 | stmmac_enable_dma_transmission(priv, priv->ioaddr); | 3233 | stmmac_enable_dma_transmission(priv, priv->ioaddr); |
| @@ -3350,9 +3354,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) | |||
| 3350 | { | 3354 | { |
| 3351 | struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; | 3355 | struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; |
| 3352 | struct stmmac_channel *ch = &priv->channel[queue]; | 3356 | struct stmmac_channel *ch = &priv->channel[queue]; |
| 3353 | unsigned int entry = rx_q->cur_rx; | 3357 | unsigned int next_entry = rx_q->cur_rx; |
| 3354 | int coe = priv->hw->rx_csum; | 3358 | int coe = priv->hw->rx_csum; |
| 3355 | unsigned int next_entry; | ||
| 3356 | unsigned int count = 0; | 3359 | unsigned int count = 0; |
| 3357 | bool xmac; | 3360 | bool xmac; |
| 3358 | 3361 | ||
| @@ -3370,10 +3373,12 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) | |||
| 3370 | stmmac_display_ring(priv, rx_head, DMA_RX_SIZE, true); | 3373 | stmmac_display_ring(priv, rx_head, DMA_RX_SIZE, true); |
| 3371 | } | 3374 | } |
| 3372 | while (count < limit) { | 3375 | while (count < limit) { |
| 3373 | int status; | 3376 | int entry, status; |
| 3374 | struct dma_desc *p; | 3377 | struct dma_desc *p; |
| 3375 | struct dma_desc *np; | 3378 | struct dma_desc *np; |
| 3376 | 3379 | ||
| 3380 | entry = next_entry; | ||
| 3381 | |||
| 3377 | if (priv->extend_desc) | 3382 | if (priv->extend_desc) |
| 3378 | p = (struct dma_desc *)(rx_q->dma_erx + entry); | 3383 | p = (struct dma_desc *)(rx_q->dma_erx + entry); |
| 3379 | else | 3384 | else |
| @@ -3429,11 +3434,12 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) | |||
| 3429 | * ignored | 3434 | * ignored |
| 3430 | */ | 3435 | */ |
| 3431 | if (frame_len > priv->dma_buf_sz) { | 3436 | if (frame_len > priv->dma_buf_sz) { |
| 3432 | netdev_err(priv->dev, | 3437 | if (net_ratelimit()) |
| 3433 | "len %d larger than size (%d)\n", | 3438 | netdev_err(priv->dev, |
| 3434 | frame_len, priv->dma_buf_sz); | 3439 | "len %d larger than size (%d)\n", |
| 3440 | frame_len, priv->dma_buf_sz); | ||
| 3435 | priv->dev->stats.rx_length_errors++; | 3441 | priv->dev->stats.rx_length_errors++; |
| 3436 | break; | 3442 | continue; |
| 3437 | } | 3443 | } |
| 3438 | 3444 | ||
| 3439 | /* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3 | 3445 | /* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3 |
| @@ -3468,7 +3474,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) | |||
| 3468 | dev_warn(priv->device, | 3474 | dev_warn(priv->device, |
| 3469 | "packet dropped\n"); | 3475 | "packet dropped\n"); |
| 3470 | priv->dev->stats.rx_dropped++; | 3476 | priv->dev->stats.rx_dropped++; |
| 3471 | break; | 3477 | continue; |
| 3472 | } | 3478 | } |
| 3473 | 3479 | ||
| 3474 | dma_sync_single_for_cpu(priv->device, | 3480 | dma_sync_single_for_cpu(priv->device, |
| @@ -3488,11 +3494,12 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) | |||
| 3488 | } else { | 3494 | } else { |
| 3489 | skb = rx_q->rx_skbuff[entry]; | 3495 | skb = rx_q->rx_skbuff[entry]; |
| 3490 | if (unlikely(!skb)) { | 3496 | if (unlikely(!skb)) { |
| 3491 | netdev_err(priv->dev, | 3497 | if (net_ratelimit()) |
| 3492 | "%s: Inconsistent Rx chain\n", | 3498 | netdev_err(priv->dev, |
| 3493 | priv->dev->name); | 3499 | "%s: Inconsistent Rx chain\n", |
| 3500 | priv->dev->name); | ||
| 3494 | priv->dev->stats.rx_dropped++; | 3501 | priv->dev->stats.rx_dropped++; |
| 3495 | break; | 3502 | continue; |
| 3496 | } | 3503 | } |
| 3497 | prefetch(skb->data - NET_IP_ALIGN); | 3504 | prefetch(skb->data - NET_IP_ALIGN); |
| 3498 | rx_q->rx_skbuff[entry] = NULL; | 3505 | rx_q->rx_skbuff[entry] = NULL; |
| @@ -3527,7 +3534,6 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) | |||
| 3527 | priv->dev->stats.rx_packets++; | 3534 | priv->dev->stats.rx_packets++; |
| 3528 | priv->dev->stats.rx_bytes += frame_len; | 3535 | priv->dev->stats.rx_bytes += frame_len; |
| 3529 | } | 3536 | } |
| 3530 | entry = next_entry; | ||
| 3531 | } | 3537 | } |
| 3532 | 3538 | ||
| 3533 | stmmac_rx_refill(priv, queue); | 3539 | stmmac_rx_refill(priv, queue); |
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c index 5174d318901e..0a920c5936b2 100644 --- a/drivers/net/ethernet/ti/netcp_ethss.c +++ b/drivers/net/ethernet/ti/netcp_ethss.c | |||
| @@ -3657,12 +3657,16 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, | |||
| 3657 | 3657 | ||
| 3658 | ret = netcp_txpipe_init(&gbe_dev->tx_pipe, netcp_device, | 3658 | ret = netcp_txpipe_init(&gbe_dev->tx_pipe, netcp_device, |
| 3659 | gbe_dev->dma_chan_name, gbe_dev->tx_queue_id); | 3659 | gbe_dev->dma_chan_name, gbe_dev->tx_queue_id); |
| 3660 | if (ret) | 3660 | if (ret) { |
| 3661 | of_node_put(interfaces); | ||
| 3661 | return ret; | 3662 | return ret; |
| 3663 | } | ||
| 3662 | 3664 | ||
| 3663 | ret = netcp_txpipe_open(&gbe_dev->tx_pipe); | 3665 | ret = netcp_txpipe_open(&gbe_dev->tx_pipe); |
| 3664 | if (ret) | 3666 | if (ret) { |
| 3667 | of_node_put(interfaces); | ||
| 3665 | return ret; | 3668 | return ret; |
| 3669 | } | ||
| 3666 | 3670 | ||
| 3667 | /* Create network interfaces */ | 3671 | /* Create network interfaces */ |
| 3668 | INIT_LIST_HEAD(&gbe_dev->gbe_intf_head); | 3672 | INIT_LIST_HEAD(&gbe_dev->gbe_intf_head); |
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index ec7e7ec24ff9..4041c75997ba 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c | |||
| @@ -1575,12 +1575,14 @@ static int axienet_probe(struct platform_device *pdev) | |||
| 1575 | ret = of_address_to_resource(np, 0, &dmares); | 1575 | ret = of_address_to_resource(np, 0, &dmares); |
| 1576 | if (ret) { | 1576 | if (ret) { |
| 1577 | dev_err(&pdev->dev, "unable to get DMA resource\n"); | 1577 | dev_err(&pdev->dev, "unable to get DMA resource\n"); |
| 1578 | of_node_put(np); | ||
| 1578 | goto free_netdev; | 1579 | goto free_netdev; |
| 1579 | } | 1580 | } |
| 1580 | lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); | 1581 | lp->dma_regs = devm_ioremap_resource(&pdev->dev, &dmares); |
| 1581 | if (IS_ERR(lp->dma_regs)) { | 1582 | if (IS_ERR(lp->dma_regs)) { |
| 1582 | dev_err(&pdev->dev, "could not map DMA regs\n"); | 1583 | dev_err(&pdev->dev, "could not map DMA regs\n"); |
| 1583 | ret = PTR_ERR(lp->dma_regs); | 1584 | ret = PTR_ERR(lp->dma_regs); |
| 1585 | of_node_put(np); | ||
| 1584 | goto free_netdev; | 1586 | goto free_netdev; |
| 1585 | } | 1587 | } |
| 1586 | lp->rx_irq = irq_of_parse_and_map(np, 1); | 1588 | lp->rx_irq = irq_of_parse_and_map(np, 1); |
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index e859ae2e42d5..49f41b64077b 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h | |||
| @@ -987,6 +987,7 @@ struct netvsc_device { | |||
| 987 | 987 | ||
| 988 | wait_queue_head_t wait_drain; | 988 | wait_queue_head_t wait_drain; |
| 989 | bool destroy; | 989 | bool destroy; |
| 990 | bool tx_disable; /* if true, do not wake up queue again */ | ||
| 990 | 991 | ||
| 991 | /* Receive buffer allocated by us but manages by NetVSP */ | 992 | /* Receive buffer allocated by us but manages by NetVSP */ |
| 992 | void *recv_buf; | 993 | void *recv_buf; |
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 813d195bbd57..e0dce373cdd9 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c | |||
| @@ -110,6 +110,7 @@ static struct netvsc_device *alloc_net_device(void) | |||
| 110 | 110 | ||
| 111 | init_waitqueue_head(&net_device->wait_drain); | 111 | init_waitqueue_head(&net_device->wait_drain); |
| 112 | net_device->destroy = false; | 112 | net_device->destroy = false; |
| 113 | net_device->tx_disable = false; | ||
| 113 | 114 | ||
| 114 | net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT; | 115 | net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT; |
| 115 | net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT; | 116 | net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT; |
| @@ -719,7 +720,7 @@ static void netvsc_send_tx_complete(struct net_device *ndev, | |||
| 719 | } else { | 720 | } else { |
| 720 | struct netdev_queue *txq = netdev_get_tx_queue(ndev, q_idx); | 721 | struct netdev_queue *txq = netdev_get_tx_queue(ndev, q_idx); |
| 721 | 722 | ||
| 722 | if (netif_tx_queue_stopped(txq) && | 723 | if (netif_tx_queue_stopped(txq) && !net_device->tx_disable && |
| 723 | (hv_get_avail_to_write_percent(&channel->outbound) > | 724 | (hv_get_avail_to_write_percent(&channel->outbound) > |
| 724 | RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) { | 725 | RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) { |
| 725 | netif_tx_wake_queue(txq); | 726 | netif_tx_wake_queue(txq); |
| @@ -874,7 +875,8 @@ static inline int netvsc_send_pkt( | |||
| 874 | } else if (ret == -EAGAIN) { | 875 | } else if (ret == -EAGAIN) { |
| 875 | netif_tx_stop_queue(txq); | 876 | netif_tx_stop_queue(txq); |
| 876 | ndev_ctx->eth_stats.stop_queue++; | 877 | ndev_ctx->eth_stats.stop_queue++; |
| 877 | if (atomic_read(&nvchan->queue_sends) < 1) { | 878 | if (atomic_read(&nvchan->queue_sends) < 1 && |
| 879 | !net_device->tx_disable) { | ||
| 878 | netif_tx_wake_queue(txq); | 880 | netif_tx_wake_queue(txq); |
| 879 | ndev_ctx->eth_stats.wake_queue++; | 881 | ndev_ctx->eth_stats.wake_queue++; |
| 880 | ret = -ENOSPC; | 882 | ret = -ENOSPC; |
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index cf4897043e83..b20fb0fb595b 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c | |||
| @@ -109,6 +109,15 @@ static void netvsc_set_rx_mode(struct net_device *net) | |||
| 109 | rcu_read_unlock(); | 109 | rcu_read_unlock(); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | static void netvsc_tx_enable(struct netvsc_device *nvscdev, | ||
| 113 | struct net_device *ndev) | ||
| 114 | { | ||
| 115 | nvscdev->tx_disable = false; | ||
| 116 | virt_wmb(); /* ensure queue wake up mechanism is on */ | ||
| 117 | |||
| 118 | netif_tx_wake_all_queues(ndev); | ||
| 119 | } | ||
| 120 | |||
| 112 | static int netvsc_open(struct net_device *net) | 121 | static int netvsc_open(struct net_device *net) |
| 113 | { | 122 | { |
| 114 | struct net_device_context *ndev_ctx = netdev_priv(net); | 123 | struct net_device_context *ndev_ctx = netdev_priv(net); |
| @@ -129,7 +138,7 @@ static int netvsc_open(struct net_device *net) | |||
| 129 | rdev = nvdev->extension; | 138 | rdev = nvdev->extension; |
| 130 | if (!rdev->link_state) { | 139 | if (!rdev->link_state) { |
| 131 | netif_carrier_on(net); | 140 | netif_carrier_on(net); |
| 132 | netif_tx_wake_all_queues(net); | 141 | netvsc_tx_enable(nvdev, net); |
| 133 | } | 142 | } |
| 134 | 143 | ||
| 135 | if (vf_netdev) { | 144 | if (vf_netdev) { |
| @@ -184,6 +193,17 @@ static int netvsc_wait_until_empty(struct netvsc_device *nvdev) | |||
| 184 | } | 193 | } |
| 185 | } | 194 | } |
| 186 | 195 | ||
| 196 | static void netvsc_tx_disable(struct netvsc_device *nvscdev, | ||
| 197 | struct net_device *ndev) | ||
| 198 | { | ||
| 199 | if (nvscdev) { | ||
| 200 | nvscdev->tx_disable = true; | ||
| 201 | virt_wmb(); /* ensure txq will not wake up after stop */ | ||
| 202 | } | ||
| 203 | |||
| 204 | netif_tx_disable(ndev); | ||
| 205 | } | ||
| 206 | |||
| 187 | static int netvsc_close(struct net_device *net) | 207 | static int netvsc_close(struct net_device *net) |
| 188 | { | 208 | { |
| 189 | struct net_device_context *net_device_ctx = netdev_priv(net); | 209 | struct net_device_context *net_device_ctx = netdev_priv(net); |
| @@ -192,7 +212,7 @@ static int netvsc_close(struct net_device *net) | |||
| 192 | struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); | 212 | struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); |
| 193 | int ret; | 213 | int ret; |
| 194 | 214 | ||
| 195 | netif_tx_disable(net); | 215 | netvsc_tx_disable(nvdev, net); |
| 196 | 216 | ||
| 197 | /* No need to close rndis filter if it is removed already */ | 217 | /* No need to close rndis filter if it is removed already */ |
| 198 | if (!nvdev) | 218 | if (!nvdev) |
| @@ -920,7 +940,7 @@ static int netvsc_detach(struct net_device *ndev, | |||
| 920 | 940 | ||
| 921 | /* If device was up (receiving) then shutdown */ | 941 | /* If device was up (receiving) then shutdown */ |
| 922 | if (netif_running(ndev)) { | 942 | if (netif_running(ndev)) { |
| 923 | netif_tx_disable(ndev); | 943 | netvsc_tx_disable(nvdev, ndev); |
| 924 | 944 | ||
| 925 | ret = rndis_filter_close(nvdev); | 945 | ret = rndis_filter_close(nvdev); |
| 926 | if (ret) { | 946 | if (ret) { |
| @@ -1908,7 +1928,7 @@ static void netvsc_link_change(struct work_struct *w) | |||
| 1908 | if (rdev->link_state) { | 1928 | if (rdev->link_state) { |
| 1909 | rdev->link_state = false; | 1929 | rdev->link_state = false; |
| 1910 | netif_carrier_on(net); | 1930 | netif_carrier_on(net); |
| 1911 | netif_tx_wake_all_queues(net); | 1931 | netvsc_tx_enable(net_device, net); |
| 1912 | } else { | 1932 | } else { |
| 1913 | notify = true; | 1933 | notify = true; |
| 1914 | } | 1934 | } |
| @@ -1918,7 +1938,7 @@ static void netvsc_link_change(struct work_struct *w) | |||
| 1918 | if (!rdev->link_state) { | 1938 | if (!rdev->link_state) { |
| 1919 | rdev->link_state = true; | 1939 | rdev->link_state = true; |
| 1920 | netif_carrier_off(net); | 1940 | netif_carrier_off(net); |
| 1921 | netif_tx_stop_all_queues(net); | 1941 | netvsc_tx_disable(net_device, net); |
| 1922 | } | 1942 | } |
| 1923 | kfree(event); | 1943 | kfree(event); |
| 1924 | break; | 1944 | break; |
| @@ -1927,7 +1947,7 @@ static void netvsc_link_change(struct work_struct *w) | |||
| 1927 | if (!rdev->link_state) { | 1947 | if (!rdev->link_state) { |
| 1928 | rdev->link_state = true; | 1948 | rdev->link_state = true; |
| 1929 | netif_carrier_off(net); | 1949 | netif_carrier_off(net); |
| 1930 | netif_tx_stop_all_queues(net); | 1950 | netvsc_tx_disable(net_device, net); |
| 1931 | event->event = RNDIS_STATUS_MEDIA_CONNECT; | 1951 | event->event = RNDIS_STATUS_MEDIA_CONNECT; |
| 1932 | spin_lock_irqsave(&ndev_ctx->lock, flags); | 1952 | spin_lock_irqsave(&ndev_ctx->lock, flags); |
| 1933 | list_add(&event->list, &ndev_ctx->reconfig_events); | 1953 | list_add(&event->list, &ndev_ctx->reconfig_events); |
diff --git a/drivers/net/ieee802154/adf7242.c b/drivers/net/ieee802154/adf7242.c index cd1d8faccca5..cd6b95e673a5 100644 --- a/drivers/net/ieee802154/adf7242.c +++ b/drivers/net/ieee802154/adf7242.c | |||
| @@ -1268,6 +1268,10 @@ static int adf7242_probe(struct spi_device *spi) | |||
| 1268 | INIT_DELAYED_WORK(&lp->work, adf7242_rx_cal_work); | 1268 | INIT_DELAYED_WORK(&lp->work, adf7242_rx_cal_work); |
| 1269 | lp->wqueue = alloc_ordered_workqueue(dev_name(&spi->dev), | 1269 | lp->wqueue = alloc_ordered_workqueue(dev_name(&spi->dev), |
| 1270 | WQ_MEM_RECLAIM); | 1270 | WQ_MEM_RECLAIM); |
| 1271 | if (unlikely(!lp->wqueue)) { | ||
| 1272 | ret = -ENOMEM; | ||
| 1273 | goto err_hw_init; | ||
| 1274 | } | ||
| 1271 | 1275 | ||
| 1272 | ret = adf7242_hw_init(lp); | 1276 | ret = adf7242_hw_init(lp); |
| 1273 | if (ret) | 1277 | if (ret) |
diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c index b6743f03dce0..3b88846de31b 100644 --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c | |||
| @@ -324,7 +324,7 @@ static int hwsim_get_radio_nl(struct sk_buff *msg, struct genl_info *info) | |||
| 324 | goto out_err; | 324 | goto out_err; |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | genlmsg_reply(skb, info); | 327 | res = genlmsg_reply(skb, info); |
| 328 | break; | 328 | break; |
| 329 | } | 329 | } |
| 330 | 330 | ||
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 071869db44cf..520657945b82 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig | |||
| @@ -7,6 +7,8 @@ menuconfig MDIO_DEVICE | |||
| 7 | help | 7 | help |
| 8 | MDIO devices and driver infrastructure code. | 8 | MDIO devices and driver infrastructure code. |
| 9 | 9 | ||
| 10 | if MDIO_DEVICE | ||
| 11 | |||
| 10 | config MDIO_BUS | 12 | config MDIO_BUS |
| 11 | tristate | 13 | tristate |
| 12 | default m if PHYLIB=m | 14 | default m if PHYLIB=m |
| @@ -179,6 +181,7 @@ config MDIO_XGENE | |||
| 179 | APM X-Gene SoC's. | 181 | APM X-Gene SoC's. |
| 180 | 182 | ||
| 181 | endif | 183 | endif |
| 184 | endif | ||
| 182 | 185 | ||
| 183 | config PHYLINK | 186 | config PHYLINK |
| 184 | tristate | 187 | tristate |
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index 9605d4fe540b..cb86a3e90c7d 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c | |||
| @@ -323,6 +323,19 @@ static int bcm54xx_config_init(struct phy_device *phydev) | |||
| 323 | 323 | ||
| 324 | bcm54xx_phydsp_config(phydev); | 324 | bcm54xx_phydsp_config(phydev); |
| 325 | 325 | ||
| 326 | /* Encode link speed into LED1 and LED3 pair (green/amber). | ||
| 327 | * Also flash these two LEDs on activity. This means configuring | ||
| 328 | * them for MULTICOLOR and encoding link/activity into them. | ||
| 329 | */ | ||
| 330 | val = BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_MULTICOLOR1) | | ||
| 331 | BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_MULTICOLOR1); | ||
| 332 | bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val); | ||
| 333 | |||
| 334 | val = BCM_LED_MULTICOLOR_IN_PHASE | | ||
| 335 | BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) | | ||
| 336 | BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT); | ||
| 337 | bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val); | ||
| 338 | |||
| 326 | return 0; | 339 | return 0; |
| 327 | } | 340 | } |
| 328 | 341 | ||
diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index bbd8c22067f3..97d45bd5b38e 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
| 16 | 16 | ||
| 17 | #define DP83822_PHY_ID 0x2000a240 | 17 | #define DP83822_PHY_ID 0x2000a240 |
| 18 | #define DP83825I_PHY_ID 0x2000a150 | ||
| 19 | |||
| 18 | #define DP83822_DEVADDR 0x1f | 20 | #define DP83822_DEVADDR 0x1f |
| 19 | 21 | ||
| 20 | #define MII_DP83822_PHYSCR 0x11 | 22 | #define MII_DP83822_PHYSCR 0x11 |
| @@ -304,26 +306,30 @@ static int dp83822_resume(struct phy_device *phydev) | |||
| 304 | return 0; | 306 | return 0; |
| 305 | } | 307 | } |
| 306 | 308 | ||
| 309 | #define DP83822_PHY_DRIVER(_id, _name) \ | ||
| 310 | { \ | ||
| 311 | PHY_ID_MATCH_MODEL(_id), \ | ||
| 312 | .name = (_name), \ | ||
| 313 | .features = PHY_BASIC_FEATURES, \ | ||
| 314 | .soft_reset = dp83822_phy_reset, \ | ||
| 315 | .config_init = dp83822_config_init, \ | ||
| 316 | .get_wol = dp83822_get_wol, \ | ||
| 317 | .set_wol = dp83822_set_wol, \ | ||
| 318 | .ack_interrupt = dp83822_ack_interrupt, \ | ||
| 319 | .config_intr = dp83822_config_intr, \ | ||
| 320 | .suspend = dp83822_suspend, \ | ||
| 321 | .resume = dp83822_resume, \ | ||
| 322 | } | ||
| 323 | |||
| 307 | static struct phy_driver dp83822_driver[] = { | 324 | static struct phy_driver dp83822_driver[] = { |
| 308 | { | 325 | DP83822_PHY_DRIVER(DP83822_PHY_ID, "TI DP83822"), |
| 309 | .phy_id = DP83822_PHY_ID, | 326 | DP83822_PHY_DRIVER(DP83825I_PHY_ID, "TI DP83825I"), |
| 310 | .phy_id_mask = 0xfffffff0, | ||
| 311 | .name = "TI DP83822", | ||
| 312 | .features = PHY_BASIC_FEATURES, | ||
| 313 | .config_init = dp83822_config_init, | ||
| 314 | .soft_reset = dp83822_phy_reset, | ||
| 315 | .get_wol = dp83822_get_wol, | ||
| 316 | .set_wol = dp83822_set_wol, | ||
| 317 | .ack_interrupt = dp83822_ack_interrupt, | ||
| 318 | .config_intr = dp83822_config_intr, | ||
| 319 | .suspend = dp83822_suspend, | ||
| 320 | .resume = dp83822_resume, | ||
| 321 | }, | ||
| 322 | }; | 327 | }; |
| 323 | module_phy_driver(dp83822_driver); | 328 | module_phy_driver(dp83822_driver); |
| 324 | 329 | ||
| 325 | static struct mdio_device_id __maybe_unused dp83822_tbl[] = { | 330 | static struct mdio_device_id __maybe_unused dp83822_tbl[] = { |
| 326 | { DP83822_PHY_ID, 0xfffffff0 }, | 331 | { DP83822_PHY_ID, 0xfffffff0 }, |
| 332 | { DP83825I_PHY_ID, 0xfffffff0 }, | ||
| 327 | { }, | 333 | { }, |
| 328 | }; | 334 | }; |
| 329 | MODULE_DEVICE_TABLE(mdio, dp83822_tbl); | 335 | MODULE_DEVICE_TABLE(mdio, dp83822_tbl); |
diff --git a/drivers/net/phy/meson-gxl.c b/drivers/net/phy/meson-gxl.c index a238388eb1a5..0eec2913c289 100644 --- a/drivers/net/phy/meson-gxl.c +++ b/drivers/net/phy/meson-gxl.c | |||
| @@ -201,6 +201,7 @@ static int meson_gxl_ack_interrupt(struct phy_device *phydev) | |||
| 201 | static int meson_gxl_config_intr(struct phy_device *phydev) | 201 | static int meson_gxl_config_intr(struct phy_device *phydev) |
| 202 | { | 202 | { |
| 203 | u16 val; | 203 | u16 val; |
| 204 | int ret; | ||
| 204 | 205 | ||
| 205 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { | 206 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { |
| 206 | val = INTSRC_ANEG_PR | 207 | val = INTSRC_ANEG_PR |
| @@ -213,6 +214,11 @@ static int meson_gxl_config_intr(struct phy_device *phydev) | |||
| 213 | val = 0; | 214 | val = 0; |
| 214 | } | 215 | } |
| 215 | 216 | ||
| 217 | /* Ack any pending IRQ */ | ||
| 218 | ret = meson_gxl_ack_interrupt(phydev); | ||
| 219 | if (ret) | ||
| 220 | return ret; | ||
| 221 | |||
| 216 | return phy_write(phydev, INTSRC_MASK, val); | 222 | return phy_write(phydev, INTSRC_MASK, val); |
| 217 | } | 223 | } |
| 218 | 224 | ||
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 49fdd1ee798e..77068c545de0 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
| @@ -1831,7 +1831,7 @@ int genphy_soft_reset(struct phy_device *phydev) | |||
| 1831 | { | 1831 | { |
| 1832 | int ret; | 1832 | int ret; |
| 1833 | 1833 | ||
| 1834 | ret = phy_write(phydev, MII_BMCR, BMCR_RESET); | 1834 | ret = phy_set_bits(phydev, MII_BMCR, BMCR_RESET); |
| 1835 | if (ret < 0) | 1835 | if (ret < 0) |
| 1836 | return ret; | 1836 | return ret; |
| 1837 | 1837 | ||
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 1d68921723dc..e9ca1c088d0b 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
| @@ -1763,9 +1763,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1763 | int skb_xdp = 1; | 1763 | int skb_xdp = 1; |
| 1764 | bool frags = tun_napi_frags_enabled(tfile); | 1764 | bool frags = tun_napi_frags_enabled(tfile); |
| 1765 | 1765 | ||
| 1766 | if (!(tun->dev->flags & IFF_UP)) | ||
| 1767 | return -EIO; | ||
| 1768 | |||
| 1769 | if (!(tun->flags & IFF_NO_PI)) { | 1766 | if (!(tun->flags & IFF_NO_PI)) { |
| 1770 | if (len < sizeof(pi)) | 1767 | if (len < sizeof(pi)) |
| 1771 | return -EINVAL; | 1768 | return -EINVAL; |
| @@ -1867,6 +1864,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1867 | err = skb_copy_datagram_from_iter(skb, 0, from, len); | 1864 | err = skb_copy_datagram_from_iter(skb, 0, from, len); |
| 1868 | 1865 | ||
| 1869 | if (err) { | 1866 | if (err) { |
| 1867 | err = -EFAULT; | ||
| 1868 | drop: | ||
| 1870 | this_cpu_inc(tun->pcpu_stats->rx_dropped); | 1869 | this_cpu_inc(tun->pcpu_stats->rx_dropped); |
| 1871 | kfree_skb(skb); | 1870 | kfree_skb(skb); |
| 1872 | if (frags) { | 1871 | if (frags) { |
| @@ -1874,7 +1873,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1874 | mutex_unlock(&tfile->napi_mutex); | 1873 | mutex_unlock(&tfile->napi_mutex); |
| 1875 | } | 1874 | } |
| 1876 | 1875 | ||
| 1877 | return -EFAULT; | 1876 | return err; |
| 1878 | } | 1877 | } |
| 1879 | } | 1878 | } |
| 1880 | 1879 | ||
| @@ -1958,6 +1957,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1958 | !tfile->detached) | 1957 | !tfile->detached) |
| 1959 | rxhash = __skb_get_hash_symmetric(skb); | 1958 | rxhash = __skb_get_hash_symmetric(skb); |
| 1960 | 1959 | ||
| 1960 | rcu_read_lock(); | ||
| 1961 | if (unlikely(!(tun->dev->flags & IFF_UP))) { | ||
| 1962 | err = -EIO; | ||
| 1963 | rcu_read_unlock(); | ||
| 1964 | goto drop; | ||
| 1965 | } | ||
| 1966 | |||
| 1961 | if (frags) { | 1967 | if (frags) { |
| 1962 | /* Exercise flow dissector code path. */ | 1968 | /* Exercise flow dissector code path. */ |
| 1963 | u32 headlen = eth_get_headlen(skb->data, skb_headlen(skb)); | 1969 | u32 headlen = eth_get_headlen(skb->data, skb_headlen(skb)); |
| @@ -1965,6 +1971,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1965 | if (unlikely(headlen > skb_headlen(skb))) { | 1971 | if (unlikely(headlen > skb_headlen(skb))) { |
| 1966 | this_cpu_inc(tun->pcpu_stats->rx_dropped); | 1972 | this_cpu_inc(tun->pcpu_stats->rx_dropped); |
| 1967 | napi_free_frags(&tfile->napi); | 1973 | napi_free_frags(&tfile->napi); |
| 1974 | rcu_read_unlock(); | ||
| 1968 | mutex_unlock(&tfile->napi_mutex); | 1975 | mutex_unlock(&tfile->napi_mutex); |
| 1969 | WARN_ON(1); | 1976 | WARN_ON(1); |
| 1970 | return -ENOMEM; | 1977 | return -ENOMEM; |
| @@ -1992,6 +1999,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, | |||
| 1992 | } else { | 1999 | } else { |
| 1993 | netif_rx_ni(skb); | 2000 | netif_rx_ni(skb); |
| 1994 | } | 2001 | } |
| 2002 | rcu_read_unlock(); | ||
| 1995 | 2003 | ||
| 1996 | stats = get_cpu_ptr(tun->pcpu_stats); | 2004 | stats = get_cpu_ptr(tun->pcpu_stats); |
| 1997 | u64_stats_update_begin(&stats->syncp); | 2005 | u64_stats_update_begin(&stats->syncp); |
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c index 820a2fe7d027..aff995be2a31 100644 --- a/drivers/net/usb/aqc111.c +++ b/drivers/net/usb/aqc111.c | |||
| @@ -1301,6 +1301,20 @@ static const struct driver_info trendnet_info = { | |||
| 1301 | .tx_fixup = aqc111_tx_fixup, | 1301 | .tx_fixup = aqc111_tx_fixup, |
| 1302 | }; | 1302 | }; |
| 1303 | 1303 | ||
| 1304 | static const struct driver_info qnap_info = { | ||
| 1305 | .description = "QNAP QNA-UC5G1T USB to 5GbE Adapter", | ||
| 1306 | .bind = aqc111_bind, | ||
| 1307 | .unbind = aqc111_unbind, | ||
| 1308 | .status = aqc111_status, | ||
| 1309 | .link_reset = aqc111_link_reset, | ||
| 1310 | .reset = aqc111_reset, | ||
| 1311 | .stop = aqc111_stop, | ||
| 1312 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | | ||
| 1313 | FLAG_AVOID_UNLINK_URBS | FLAG_MULTI_PACKET, | ||
| 1314 | .rx_fixup = aqc111_rx_fixup, | ||
| 1315 | .tx_fixup = aqc111_tx_fixup, | ||
| 1316 | }; | ||
| 1317 | |||
| 1304 | static int aqc111_suspend(struct usb_interface *intf, pm_message_t message) | 1318 | static int aqc111_suspend(struct usb_interface *intf, pm_message_t message) |
| 1305 | { | 1319 | { |
| 1306 | struct usbnet *dev = usb_get_intfdata(intf); | 1320 | struct usbnet *dev = usb_get_intfdata(intf); |
| @@ -1455,6 +1469,7 @@ static const struct usb_device_id products[] = { | |||
| 1455 | {AQC111_USB_ETH_DEV(0x0b95, 0x2790, asix111_info)}, | 1469 | {AQC111_USB_ETH_DEV(0x0b95, 0x2790, asix111_info)}, |
| 1456 | {AQC111_USB_ETH_DEV(0x0b95, 0x2791, asix112_info)}, | 1470 | {AQC111_USB_ETH_DEV(0x0b95, 0x2791, asix112_info)}, |
| 1457 | {AQC111_USB_ETH_DEV(0x20f4, 0xe05a, trendnet_info)}, | 1471 | {AQC111_USB_ETH_DEV(0x20f4, 0xe05a, trendnet_info)}, |
| 1472 | {AQC111_USB_ETH_DEV(0x1c04, 0x0015, qnap_info)}, | ||
| 1458 | { },/* END */ | 1473 | { },/* END */ |
| 1459 | }; | 1474 | }; |
| 1460 | MODULE_DEVICE_TABLE(usb, products); | 1475 | MODULE_DEVICE_TABLE(usb, products); |
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 5512a1038721..3e9b2c319e45 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
| @@ -851,6 +851,14 @@ static const struct usb_device_id products[] = { | |||
| 851 | .driver_info = 0, | 851 | .driver_info = 0, |
| 852 | }, | 852 | }, |
| 853 | 853 | ||
| 854 | /* QNAP QNA-UC5G1T USB to 5GbE Adapter (based on AQC111U) */ | ||
| 855 | { | ||
| 856 | USB_DEVICE_AND_INTERFACE_INFO(0x1c04, 0x0015, USB_CLASS_COMM, | ||
| 857 | USB_CDC_SUBCLASS_ETHERNET, | ||
| 858 | USB_CDC_PROTO_NONE), | ||
| 859 | .driver_info = 0, | ||
| 860 | }, | ||
| 861 | |||
| 854 | /* WHITELIST!!! | 862 | /* WHITELIST!!! |
| 855 | * | 863 | * |
| 856 | * CDC Ether uses two interfaces, not necessarily consecutive. | 864 | * CDC Ether uses two interfaces, not necessarily consecutive. |
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 74bebbdb4b15..9195f3476b1d 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c | |||
| @@ -1203,6 +1203,7 @@ static const struct usb_device_id products[] = { | |||
| 1203 | {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ | 1203 | {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ |
| 1204 | {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */ | 1204 | {QMI_FIXED_INTF(0x2001, 0x7e19, 4)}, /* D-Link DWM-221 B1 */ |
| 1205 | {QMI_FIXED_INTF(0x2001, 0x7e35, 4)}, /* D-Link DWM-222 */ | 1205 | {QMI_FIXED_INTF(0x2001, 0x7e35, 4)}, /* D-Link DWM-222 */ |
| 1206 | {QMI_FIXED_INTF(0x2020, 0x2031, 4)}, /* Olicard 600 */ | ||
| 1206 | {QMI_FIXED_INTF(0x2020, 0x2033, 4)}, /* BroadMobi BM806U */ | 1207 | {QMI_FIXED_INTF(0x2020, 0x2033, 4)}, /* BroadMobi BM806U */ |
| 1207 | {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ | 1208 | {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ |
| 1208 | {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ | 1209 | {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ |
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index 7c1430ed0244..cd15c32b2e43 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c | |||
| @@ -1273,9 +1273,14 @@ static void vrf_setup(struct net_device *dev) | |||
| 1273 | 1273 | ||
| 1274 | /* default to no qdisc; user can add if desired */ | 1274 | /* default to no qdisc; user can add if desired */ |
| 1275 | dev->priv_flags |= IFF_NO_QUEUE; | 1275 | dev->priv_flags |= IFF_NO_QUEUE; |
| 1276 | dev->priv_flags |= IFF_NO_RX_HANDLER; | ||
| 1276 | 1277 | ||
| 1277 | dev->min_mtu = 0; | 1278 | /* VRF devices do not care about MTU, but if the MTU is set |
| 1278 | dev->max_mtu = 0; | 1279 | * too low then the ipv4 and ipv6 protocols are disabled |
| 1280 | * which breaks networking. | ||
| 1281 | */ | ||
| 1282 | dev->min_mtu = IPV6_MIN_MTU; | ||
| 1283 | dev->max_mtu = ETH_MAX_MTU; | ||
| 1279 | } | 1284 | } |
| 1280 | 1285 | ||
| 1281 | static int vrf_validate(struct nlattr *tb[], struct nlattr *data[], | 1286 | static int vrf_validate(struct nlattr *tb[], struct nlattr *data[], |
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 077f1b9f2761..d76dfed8d9bb 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
| @@ -4335,10 +4335,8 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head) | |||
| 4335 | /* If vxlan->dev is in the same netns, it has already been added | 4335 | /* If vxlan->dev is in the same netns, it has already been added |
| 4336 | * to the list by the previous loop. | 4336 | * to the list by the previous loop. |
| 4337 | */ | 4337 | */ |
| 4338 | if (!net_eq(dev_net(vxlan->dev), net)) { | 4338 | if (!net_eq(dev_net(vxlan->dev), net)) |
| 4339 | gro_cells_destroy(&vxlan->gro_cells); | ||
| 4340 | unregister_netdevice_queue(vxlan->dev, head); | 4339 | unregister_netdevice_queue(vxlan->dev, head); |
| 4341 | } | ||
| 4342 | } | 4340 | } |
| 4343 | 4341 | ||
| 4344 | for (h = 0; h < PORT_HASH_SIZE; ++h) | 4342 | for (h = 0; h < PORT_HASH_SIZE; ++h) |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c index e9822a3ec373..94132cfd1f56 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | |||
| @@ -460,9 +460,7 @@ static int iwl_mvm_ftm_range_resp_valid(struct iwl_mvm *mvm, u8 request_id, | |||
| 460 | static void iwl_mvm_debug_range_resp(struct iwl_mvm *mvm, u8 index, | 460 | static void iwl_mvm_debug_range_resp(struct iwl_mvm *mvm, u8 index, |
| 461 | struct cfg80211_pmsr_result *res) | 461 | struct cfg80211_pmsr_result *res) |
| 462 | { | 462 | { |
| 463 | s64 rtt_avg = res->ftm.rtt_avg * 100; | 463 | s64 rtt_avg = div_s64(res->ftm.rtt_avg * 100, 6666); |
| 464 | |||
| 465 | do_div(rtt_avg, 6666); | ||
| 466 | 464 | ||
| 467 | IWL_DEBUG_INFO(mvm, "entry %d\n", index); | 465 | IWL_DEBUG_INFO(mvm, "entry %d\n", index); |
| 468 | IWL_DEBUG_INFO(mvm, "\tstatus: %d\n", res->status); | 466 | IWL_DEBUG_INFO(mvm, "\tstatus: %d\n", res->status); |
diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index 6eedc0ec7661..76629b98c78d 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c | |||
| @@ -130,6 +130,8 @@ mt76_dma_tx_cleanup_idx(struct mt76_dev *dev, struct mt76_queue *q, int idx, | |||
| 130 | static void | 130 | static void |
| 131 | mt76_dma_sync_idx(struct mt76_dev *dev, struct mt76_queue *q) | 131 | mt76_dma_sync_idx(struct mt76_dev *dev, struct mt76_queue *q) |
| 132 | { | 132 | { |
| 133 | iowrite32(q->desc_dma, &q->regs->desc_base); | ||
| 134 | iowrite32(q->ndesc, &q->regs->ring_size); | ||
| 133 | q->head = ioread32(&q->regs->dma_idx); | 135 | q->head = ioread32(&q->regs->dma_idx); |
| 134 | q->tail = q->head; | 136 | q->tail = q->head; |
| 135 | iowrite32(q->head, &q->regs->cpu_idx); | 137 | iowrite32(q->head, &q->regs->cpu_idx); |
| @@ -180,7 +182,10 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush) | |||
| 180 | else | 182 | else |
| 181 | mt76_dma_sync_idx(dev, q); | 183 | mt76_dma_sync_idx(dev, q); |
| 182 | 184 | ||
| 183 | wake = wake && qid < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8; | 185 | wake = wake && q->stopped && |
| 186 | qid < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8; | ||
| 187 | if (wake) | ||
| 188 | q->stopped = false; | ||
| 184 | 189 | ||
| 185 | if (!q->queued) | 190 | if (!q->queued) |
| 186 | wake_up(&dev->tx_wait); | 191 | wake_up(&dev->tx_wait); |
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index a033745adb2f..316167404729 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c | |||
| @@ -679,19 +679,15 @@ out: | |||
| 679 | return ret; | 679 | return ret; |
| 680 | } | 680 | } |
| 681 | 681 | ||
| 682 | static void | 682 | void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 683 | mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, | 683 | struct ieee80211_sta *sta) |
| 684 | struct ieee80211_sta *sta) | ||
| 685 | { | 684 | { |
| 686 | struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; | 685 | struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv; |
| 687 | int idx = wcid->idx; | 686 | int i, idx = wcid->idx; |
| 688 | int i; | ||
| 689 | 687 | ||
| 690 | rcu_assign_pointer(dev->wcid[idx], NULL); | 688 | rcu_assign_pointer(dev->wcid[idx], NULL); |
| 691 | synchronize_rcu(); | 689 | synchronize_rcu(); |
| 692 | 690 | ||
| 693 | mutex_lock(&dev->mutex); | ||
| 694 | |||
| 695 | if (dev->drv->sta_remove) | 691 | if (dev->drv->sta_remove) |
| 696 | dev->drv->sta_remove(dev, vif, sta); | 692 | dev->drv->sta_remove(dev, vif, sta); |
| 697 | 693 | ||
| @@ -699,7 +695,15 @@ mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, | |||
| 699 | for (i = 0; i < ARRAY_SIZE(sta->txq); i++) | 695 | for (i = 0; i < ARRAY_SIZE(sta->txq); i++) |
| 700 | mt76_txq_remove(dev, sta->txq[i]); | 696 | mt76_txq_remove(dev, sta->txq[i]); |
| 701 | mt76_wcid_free(dev->wcid_mask, idx); | 697 | mt76_wcid_free(dev->wcid_mask, idx); |
| 698 | } | ||
| 699 | EXPORT_SYMBOL_GPL(__mt76_sta_remove); | ||
| 702 | 700 | ||
| 701 | static void | ||
| 702 | mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, | ||
| 703 | struct ieee80211_sta *sta) | ||
| 704 | { | ||
| 705 | mutex_lock(&dev->mutex); | ||
| 706 | __mt76_sta_remove(dev, vif, sta); | ||
| 703 | mutex_unlock(&dev->mutex); | 707 | mutex_unlock(&dev->mutex); |
| 704 | } | 708 | } |
| 705 | 709 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 5dfb0601f101..bcbfd3c4a44b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h | |||
| @@ -126,6 +126,7 @@ struct mt76_queue { | |||
| 126 | int ndesc; | 126 | int ndesc; |
| 127 | int queued; | 127 | int queued; |
| 128 | int buf_size; | 128 | int buf_size; |
| 129 | bool stopped; | ||
| 129 | 130 | ||
| 130 | u8 buf_offset; | 131 | u8 buf_offset; |
| 131 | u8 hw_idx; | 132 | u8 hw_idx; |
| @@ -143,6 +144,7 @@ struct mt76_mcu_ops { | |||
| 143 | const struct mt76_reg_pair *rp, int len); | 144 | const struct mt76_reg_pair *rp, int len); |
| 144 | int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base, | 145 | int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base, |
| 145 | struct mt76_reg_pair *rp, int len); | 146 | struct mt76_reg_pair *rp, int len); |
| 147 | int (*mcu_restart)(struct mt76_dev *dev); | ||
| 146 | }; | 148 | }; |
| 147 | 149 | ||
| 148 | struct mt76_queue_ops { | 150 | struct mt76_queue_ops { |
| @@ -693,6 +695,8 @@ int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | |||
| 693 | struct ieee80211_sta *sta, | 695 | struct ieee80211_sta *sta, |
| 694 | enum ieee80211_sta_state old_state, | 696 | enum ieee80211_sta_state old_state, |
| 695 | enum ieee80211_sta_state new_state); | 697 | enum ieee80211_sta_state new_state); |
| 698 | void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, | ||
| 699 | struct ieee80211_sta *sta); | ||
| 696 | 700 | ||
| 697 | struct ieee80211_sta *mt76_rx_convert(struct sk_buff *skb); | 701 | struct ieee80211_sta *mt76_rx_convert(struct sk_buff *skb); |
| 698 | 702 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/beacon.c b/drivers/net/wireless/mediatek/mt76/mt7603/beacon.c index afcd86f735b4..4dcb465095d1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/beacon.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/beacon.c | |||
| @@ -135,8 +135,7 @@ void mt7603_pre_tbtt_tasklet(unsigned long arg) | |||
| 135 | 135 | ||
| 136 | out: | 136 | out: |
| 137 | mt76_queue_tx_cleanup(dev, MT_TXQ_BEACON, false); | 137 | mt76_queue_tx_cleanup(dev, MT_TXQ_BEACON, false); |
| 138 | if (dev->mt76.q_tx[MT_TXQ_BEACON].queued > | 138 | if (dev->mt76.q_tx[MT_TXQ_BEACON].queued > hweight8(dev->beacon_mask)) |
| 139 | __sw_hweight8(dev->beacon_mask)) | ||
| 140 | dev->beacon_check++; | 139 | dev->beacon_check++; |
| 141 | } | 140 | } |
| 142 | 141 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/dma.c b/drivers/net/wireless/mediatek/mt76/mt7603/dma.c index d69e82c66ab2..b3ae0aaea62a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/dma.c | |||
| @@ -27,12 +27,16 @@ static void | |||
| 27 | mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb) | 27 | mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb) |
| 28 | { | 28 | { |
| 29 | __le32 *txd = (__le32 *)skb->data; | 29 | __le32 *txd = (__le32 *)skb->data; |
| 30 | struct ieee80211_hdr *hdr; | ||
| 31 | struct ieee80211_sta *sta; | ||
| 30 | struct mt7603_sta *msta; | 32 | struct mt7603_sta *msta; |
| 31 | struct mt76_wcid *wcid; | 33 | struct mt76_wcid *wcid; |
| 34 | void *priv; | ||
| 32 | int idx; | 35 | int idx; |
| 33 | u32 val; | 36 | u32 val; |
| 37 | u8 tid; | ||
| 34 | 38 | ||
| 35 | if (skb->len < sizeof(MT_TXD_SIZE) + sizeof(struct ieee80211_hdr)) | 39 | if (skb->len < MT_TXD_SIZE + sizeof(struct ieee80211_hdr)) |
| 36 | goto free; | 40 | goto free; |
| 37 | 41 | ||
| 38 | val = le32_to_cpu(txd[1]); | 42 | val = le32_to_cpu(txd[1]); |
| @@ -46,10 +50,19 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb) | |||
| 46 | if (!wcid) | 50 | if (!wcid) |
| 47 | goto free; | 51 | goto free; |
| 48 | 52 | ||
| 49 | msta = container_of(wcid, struct mt7603_sta, wcid); | 53 | priv = msta = container_of(wcid, struct mt7603_sta, wcid); |
| 50 | val = le32_to_cpu(txd[0]); | 54 | val = le32_to_cpu(txd[0]); |
| 51 | skb_set_queue_mapping(skb, FIELD_GET(MT_TXD0_Q_IDX, val)); | 55 | skb_set_queue_mapping(skb, FIELD_GET(MT_TXD0_Q_IDX, val)); |
| 52 | 56 | ||
| 57 | val &= ~(MT_TXD0_P_IDX | MT_TXD0_Q_IDX); | ||
| 58 | val |= FIELD_PREP(MT_TXD0_Q_IDX, MT_TX_HW_QUEUE_MGMT); | ||
| 59 | txd[0] = cpu_to_le32(val); | ||
| 60 | |||
| 61 | sta = container_of(priv, struct ieee80211_sta, drv_priv); | ||
| 62 | hdr = (struct ieee80211_hdr *) &skb->data[MT_TXD_SIZE]; | ||
| 63 | tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK; | ||
| 64 | ieee80211_sta_set_buffered(sta, tid, true); | ||
| 65 | |||
| 53 | spin_lock_bh(&dev->ps_lock); | 66 | spin_lock_bh(&dev->ps_lock); |
| 54 | __skb_queue_tail(&msta->psq, skb); | 67 | __skb_queue_tail(&msta->psq, skb); |
| 55 | if (skb_queue_len(&msta->psq) >= 64) { | 68 | if (skb_queue_len(&msta->psq) >= 64) { |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/init.c b/drivers/net/wireless/mediatek/mt76/mt7603/init.c index 15cc8f33b34d..d54dda67d036 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/init.c | |||
| @@ -112,7 +112,7 @@ static void | |||
| 112 | mt7603_phy_init(struct mt7603_dev *dev) | 112 | mt7603_phy_init(struct mt7603_dev *dev) |
| 113 | { | 113 | { |
| 114 | int rx_chains = dev->mt76.antenna_mask; | 114 | int rx_chains = dev->mt76.antenna_mask; |
| 115 | int tx_chains = __sw_hweight8(rx_chains) - 1; | 115 | int tx_chains = hweight8(rx_chains) - 1; |
| 116 | 116 | ||
| 117 | mt76_rmw(dev, MT_WF_RMAC_RMCR, | 117 | mt76_rmw(dev, MT_WF_RMAC_RMCR, |
| 118 | (MT_WF_RMAC_RMCR_SMPS_MODE | | 118 | (MT_WF_RMAC_RMCR_SMPS_MODE | |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c index 0a0115861b51..5e31d7da96fc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c | |||
| @@ -1072,7 +1072,7 @@ out: | |||
| 1072 | case MT_PHY_TYPE_HT: | 1072 | case MT_PHY_TYPE_HT: |
| 1073 | final_rate_flags |= IEEE80211_TX_RC_MCS; | 1073 | final_rate_flags |= IEEE80211_TX_RC_MCS; |
| 1074 | final_rate &= GENMASK(5, 0); | 1074 | final_rate &= GENMASK(5, 0); |
| 1075 | if (i > 15) | 1075 | if (final_rate > 15) |
| 1076 | return false; | 1076 | return false; |
| 1077 | break; | 1077 | break; |
| 1078 | default: | 1078 | default: |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/main.c b/drivers/net/wireless/mediatek/mt76/mt7603/main.c index b10775ed92e6..cc0fe0933b2d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/main.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <linux/pci.h> | 5 | #include <linux/pci.h> |
| 6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
| 7 | #include "mt7603.h" | 7 | #include "mt7603.h" |
| 8 | #include "mac.h" | ||
| 8 | #include "eeprom.h" | 9 | #include "eeprom.h" |
| 9 | 10 | ||
| 10 | static int | 11 | static int |
| @@ -386,6 +387,15 @@ mt7603_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps) | |||
| 386 | } | 387 | } |
| 387 | 388 | ||
| 388 | static void | 389 | static void |
| 390 | mt7603_ps_set_more_data(struct sk_buff *skb) | ||
| 391 | { | ||
| 392 | struct ieee80211_hdr *hdr; | ||
| 393 | |||
| 394 | hdr = (struct ieee80211_hdr *) &skb->data[MT_TXD_SIZE]; | ||
| 395 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); | ||
| 396 | } | ||
| 397 | |||
| 398 | static void | ||
| 389 | mt7603_release_buffered_frames(struct ieee80211_hw *hw, | 399 | mt7603_release_buffered_frames(struct ieee80211_hw *hw, |
| 390 | struct ieee80211_sta *sta, | 400 | struct ieee80211_sta *sta, |
| 391 | u16 tids, int nframes, | 401 | u16 tids, int nframes, |
| @@ -399,6 +409,8 @@ mt7603_release_buffered_frames(struct ieee80211_hw *hw, | |||
| 399 | 409 | ||
| 400 | __skb_queue_head_init(&list); | 410 | __skb_queue_head_init(&list); |
| 401 | 411 | ||
| 412 | mt7603_wtbl_set_ps(dev, msta, false); | ||
| 413 | |||
| 402 | spin_lock_bh(&dev->ps_lock); | 414 | spin_lock_bh(&dev->ps_lock); |
| 403 | skb_queue_walk_safe(&msta->psq, skb, tmp) { | 415 | skb_queue_walk_safe(&msta->psq, skb, tmp) { |
| 404 | if (!nframes) | 416 | if (!nframes) |
| @@ -409,11 +421,15 @@ mt7603_release_buffered_frames(struct ieee80211_hw *hw, | |||
| 409 | 421 | ||
| 410 | skb_set_queue_mapping(skb, MT_TXQ_PSD); | 422 | skb_set_queue_mapping(skb, MT_TXQ_PSD); |
| 411 | __skb_unlink(skb, &msta->psq); | 423 | __skb_unlink(skb, &msta->psq); |
| 424 | mt7603_ps_set_more_data(skb); | ||
| 412 | __skb_queue_tail(&list, skb); | 425 | __skb_queue_tail(&list, skb); |
| 413 | nframes--; | 426 | nframes--; |
| 414 | } | 427 | } |
| 415 | spin_unlock_bh(&dev->ps_lock); | 428 | spin_unlock_bh(&dev->ps_lock); |
| 416 | 429 | ||
| 430 | if (!skb_queue_empty(&list)) | ||
| 431 | ieee80211_sta_eosp(sta); | ||
| 432 | |||
| 417 | mt7603_ps_tx_list(dev, &list); | 433 | mt7603_ps_tx_list(dev, &list); |
| 418 | 434 | ||
| 419 | if (nframes) | 435 | if (nframes) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c index 4b0713f1fd5e..d06905ea8cc6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | |||
| @@ -433,7 +433,7 @@ int mt7603_mcu_set_channel(struct mt7603_dev *dev) | |||
| 433 | { | 433 | { |
| 434 | struct cfg80211_chan_def *chandef = &dev->mt76.chandef; | 434 | struct cfg80211_chan_def *chandef = &dev->mt76.chandef; |
| 435 | struct ieee80211_hw *hw = mt76_hw(dev); | 435 | struct ieee80211_hw *hw = mt76_hw(dev); |
| 436 | int n_chains = __sw_hweight8(dev->mt76.antenna_mask); | 436 | int n_chains = hweight8(dev->mt76.antenna_mask); |
| 437 | struct { | 437 | struct { |
| 438 | u8 control_chan; | 438 | u8 control_chan; |
| 439 | u8 center_chan; | 439 | u8 center_chan; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/soc.c b/drivers/net/wireless/mediatek/mt76/mt7603/soc.c index e13fea80d970..b920be1f5718 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/soc.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/soc.c | |||
| @@ -23,9 +23,9 @@ mt76_wmac_probe(struct platform_device *pdev) | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | mem_base = devm_ioremap_resource(&pdev->dev, res); | 25 | mem_base = devm_ioremap_resource(&pdev->dev, res); |
| 26 | if (!mem_base) { | 26 | if (IS_ERR(mem_base)) { |
| 27 | dev_err(&pdev->dev, "Failed to get memory resource\n"); | 27 | dev_err(&pdev->dev, "Failed to get memory resource\n"); |
| 28 | return -EINVAL; | 28 | return PTR_ERR(mem_base); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7603_ops, | 31 | mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7603_ops, |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h b/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h index 0290ba5869a5..736f81752b5b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/initvals.h | |||
| @@ -46,7 +46,7 @@ static const struct mt76_reg_pair common_mac_reg_table[] = { | |||
| 46 | { MT_MM20_PROT_CFG, 0x01742004 }, | 46 | { MT_MM20_PROT_CFG, 0x01742004 }, |
| 47 | { MT_MM40_PROT_CFG, 0x03f42084 }, | 47 | { MT_MM40_PROT_CFG, 0x03f42084 }, |
| 48 | { MT_TXOP_CTRL_CFG, 0x0000583f }, | 48 | { MT_TXOP_CTRL_CFG, 0x0000583f }, |
| 49 | { MT_TX_RTS_CFG, 0x00092b20 }, | 49 | { MT_TX_RTS_CFG, 0x00ffff20 }, |
| 50 | { MT_EXP_ACK_TIME, 0x002400ca }, | 50 | { MT_EXP_ACK_TIME, 0x002400ca }, |
| 51 | { MT_TXOP_HLDR_ET, 0x00000002 }, | 51 | { MT_TXOP_HLDR_ET, 0x00000002 }, |
| 52 | { MT_XIFS_TIME_CFG, 0x33a41010 }, | 52 | { MT_XIFS_TIME_CFG, 0x33a41010 }, |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c index 91718647da02..e5a06f74a6f7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | |||
| @@ -229,7 +229,7 @@ static int mt76x0u_probe(struct usb_interface *usb_intf, | |||
| 229 | struct usb_device *usb_dev = interface_to_usbdev(usb_intf); | 229 | struct usb_device *usb_dev = interface_to_usbdev(usb_intf); |
| 230 | struct mt76x02_dev *dev; | 230 | struct mt76x02_dev *dev; |
| 231 | struct mt76_dev *mdev; | 231 | struct mt76_dev *mdev; |
| 232 | u32 asic_rev, mac_rev; | 232 | u32 mac_rev; |
| 233 | int ret; | 233 | int ret; |
| 234 | 234 | ||
| 235 | mdev = mt76_alloc_device(&usb_intf->dev, sizeof(*dev), &mt76x0u_ops, | 235 | mdev = mt76_alloc_device(&usb_intf->dev, sizeof(*dev), &mt76x0u_ops, |
| @@ -262,10 +262,14 @@ static int mt76x0u_probe(struct usb_interface *usb_intf, | |||
| 262 | goto err; | 262 | goto err; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | asic_rev = mt76_rr(dev, MT_ASIC_VERSION); | 265 | mdev->rev = mt76_rr(dev, MT_ASIC_VERSION); |
| 266 | mac_rev = mt76_rr(dev, MT_MAC_CSR0); | 266 | mac_rev = mt76_rr(dev, MT_MAC_CSR0); |
| 267 | dev_info(mdev->dev, "ASIC revision: %08x MAC revision: %08x\n", | 267 | dev_info(mdev->dev, "ASIC revision: %08x MAC revision: %08x\n", |
| 268 | asic_rev, mac_rev); | 268 | mdev->rev, mac_rev); |
| 269 | if (!is_mt76x0(dev)) { | ||
| 270 | ret = -ENODEV; | ||
| 271 | goto err; | ||
| 272 | } | ||
| 269 | 273 | ||
| 270 | /* Note: vendor driver skips this check for MT76X0U */ | 274 | /* Note: vendor driver skips this check for MT76X0U */ |
| 271 | if (!(mt76_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) | 275 | if (!(mt76_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h index 6915cce5def9..07061eb4d1e1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h | |||
| @@ -51,6 +51,7 @@ struct mt76x02_calibration { | |||
| 51 | u16 false_cca; | 51 | u16 false_cca; |
| 52 | s8 avg_rssi_all; | 52 | s8 avg_rssi_all; |
| 53 | s8 agc_gain_adjust; | 53 | s8 agc_gain_adjust; |
| 54 | s8 agc_lowest_gain; | ||
| 54 | s8 low_gain; | 55 | s8 low_gain; |
| 55 | 56 | ||
| 56 | s8 temp_vco; | 57 | s8 temp_vco; |
| @@ -114,8 +115,11 @@ struct mt76x02_dev { | |||
| 114 | struct mt76x02_dfs_pattern_detector dfs_pd; | 115 | struct mt76x02_dfs_pattern_detector dfs_pd; |
| 115 | 116 | ||
| 116 | /* edcca monitor */ | 117 | /* edcca monitor */ |
| 118 | unsigned long ed_trigger_timeout; | ||
| 117 | bool ed_tx_blocked; | 119 | bool ed_tx_blocked; |
| 118 | bool ed_monitor; | 120 | bool ed_monitor; |
| 121 | u8 ed_monitor_enabled; | ||
| 122 | u8 ed_monitor_learning; | ||
| 119 | u8 ed_trigger; | 123 | u8 ed_trigger; |
| 120 | u8 ed_silent; | 124 | u8 ed_silent; |
| 121 | ktime_t ed_time; | 125 | ktime_t ed_time; |
| @@ -188,6 +192,13 @@ void mt76x02_mac_start(struct mt76x02_dev *dev); | |||
| 188 | 192 | ||
| 189 | void mt76x02_init_debugfs(struct mt76x02_dev *dev); | 193 | void mt76x02_init_debugfs(struct mt76x02_dev *dev); |
| 190 | 194 | ||
| 195 | static inline bool is_mt76x0(struct mt76x02_dev *dev) | ||
| 196 | { | ||
| 197 | return mt76_chip(&dev->mt76) == 0x7610 || | ||
| 198 | mt76_chip(&dev->mt76) == 0x7630 || | ||
| 199 | mt76_chip(&dev->mt76) == 0x7650; | ||
| 200 | } | ||
| 201 | |||
| 191 | static inline bool is_mt76x2(struct mt76x02_dev *dev) | 202 | static inline bool is_mt76x2(struct mt76x02_dev *dev) |
| 192 | { | 203 | { |
| 193 | return mt76_chip(&dev->mt76) == 0x7612 || | 204 | return mt76_chip(&dev->mt76) == 0x7612 || |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c b/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c index 7580c5c986ff..b1d6fd4861e3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c | |||
| @@ -116,6 +116,32 @@ static int read_agc(struct seq_file *file, void *data) | |||
| 116 | return 0; | 116 | return 0; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | static int | ||
| 120 | mt76_edcca_set(void *data, u64 val) | ||
| 121 | { | ||
| 122 | struct mt76x02_dev *dev = data; | ||
| 123 | enum nl80211_dfs_regions region = dev->dfs_pd.region; | ||
| 124 | |||
| 125 | dev->ed_monitor_enabled = !!val; | ||
| 126 | dev->ed_monitor = dev->ed_monitor_enabled && | ||
| 127 | region == NL80211_DFS_ETSI; | ||
| 128 | mt76x02_edcca_init(dev, true); | ||
| 129 | |||
| 130 | return 0; | ||
| 131 | } | ||
| 132 | |||
| 133 | static int | ||
| 134 | mt76_edcca_get(void *data, u64 *val) | ||
| 135 | { | ||
| 136 | struct mt76x02_dev *dev = data; | ||
| 137 | |||
| 138 | *val = dev->ed_monitor_enabled; | ||
| 139 | return 0; | ||
| 140 | } | ||
| 141 | |||
| 142 | DEFINE_DEBUGFS_ATTRIBUTE(fops_edcca, mt76_edcca_get, mt76_edcca_set, | ||
| 143 | "%lld\n"); | ||
| 144 | |||
| 119 | void mt76x02_init_debugfs(struct mt76x02_dev *dev) | 145 | void mt76x02_init_debugfs(struct mt76x02_dev *dev) |
| 120 | { | 146 | { |
| 121 | struct dentry *dir; | 147 | struct dentry *dir; |
| @@ -127,6 +153,7 @@ void mt76x02_init_debugfs(struct mt76x02_dev *dev) | |||
| 127 | debugfs_create_u8("temperature", 0400, dir, &dev->cal.temp); | 153 | debugfs_create_u8("temperature", 0400, dir, &dev->cal.temp); |
| 128 | debugfs_create_bool("tpc", 0600, dir, &dev->enable_tpc); | 154 | debugfs_create_bool("tpc", 0600, dir, &dev->enable_tpc); |
| 129 | 155 | ||
| 156 | debugfs_create_file("edcca", 0400, dir, dev, &fops_edcca); | ||
| 130 | debugfs_create_file("ampdu_stat", 0400, dir, dev, &fops_ampdu_stat); | 157 | debugfs_create_file("ampdu_stat", 0400, dir, dev, &fops_ampdu_stat); |
| 131 | debugfs_create_file("dfs_stats", 0400, dir, dev, &fops_dfs_stat); | 158 | debugfs_create_file("dfs_stats", 0400, dir, dev, &fops_dfs_stat); |
| 132 | debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir, | 159 | debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir, |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c b/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c index e4649103efd4..17d12d212d1b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_dfs.c | |||
| @@ -885,7 +885,8 @@ mt76x02_dfs_set_domain(struct mt76x02_dev *dev, | |||
| 885 | if (dfs_pd->region != region) { | 885 | if (dfs_pd->region != region) { |
| 886 | tasklet_disable(&dfs_pd->dfs_tasklet); | 886 | tasklet_disable(&dfs_pd->dfs_tasklet); |
| 887 | 887 | ||
| 888 | dev->ed_monitor = region == NL80211_DFS_ETSI; | 888 | dev->ed_monitor = dev->ed_monitor_enabled && |
| 889 | region == NL80211_DFS_ETSI; | ||
| 889 | mt76x02_edcca_init(dev, true); | 890 | mt76x02_edcca_init(dev, true); |
| 890 | 891 | ||
| 891 | dfs_pd->region = region; | 892 | dfs_pd->region = region; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c index 91ff6598eccf..9ed231abe916 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | |||
| @@ -67,12 +67,39 @@ int mt76x02_mac_shared_key_setup(struct mt76x02_dev *dev, u8 vif_idx, | |||
| 67 | } | 67 | } |
| 68 | EXPORT_SYMBOL_GPL(mt76x02_mac_shared_key_setup); | 68 | EXPORT_SYMBOL_GPL(mt76x02_mac_shared_key_setup); |
| 69 | 69 | ||
| 70 | void mt76x02_mac_wcid_sync_pn(struct mt76x02_dev *dev, u8 idx, | ||
| 71 | struct ieee80211_key_conf *key) | ||
| 72 | { | ||
| 73 | enum mt76x02_cipher_type cipher; | ||
| 74 | u8 key_data[32]; | ||
| 75 | u32 iv, eiv; | ||
| 76 | u64 pn; | ||
| 77 | |||
| 78 | cipher = mt76x02_mac_get_key_info(key, key_data); | ||
| 79 | iv = mt76_rr(dev, MT_WCID_IV(idx)); | ||
| 80 | eiv = mt76_rr(dev, MT_WCID_IV(idx) + 4); | ||
| 81 | |||
| 82 | pn = (u64)eiv << 16; | ||
| 83 | if (cipher == MT_CIPHER_TKIP) { | ||
| 84 | pn |= (iv >> 16) & 0xff; | ||
| 85 | pn |= (iv & 0xff) << 8; | ||
| 86 | } else if (cipher >= MT_CIPHER_AES_CCMP) { | ||
| 87 | pn |= iv & 0xffff; | ||
| 88 | } else { | ||
| 89 | return; | ||
| 90 | } | ||
| 91 | |||
| 92 | atomic64_set(&key->tx_pn, pn); | ||
| 93 | } | ||
| 94 | |||
| 95 | |||
| 70 | int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, | 96 | int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, |
| 71 | struct ieee80211_key_conf *key) | 97 | struct ieee80211_key_conf *key) |
| 72 | { | 98 | { |
| 73 | enum mt76x02_cipher_type cipher; | 99 | enum mt76x02_cipher_type cipher; |
| 74 | u8 key_data[32]; | 100 | u8 key_data[32]; |
| 75 | u8 iv_data[8]; | 101 | u8 iv_data[8]; |
| 102 | u64 pn; | ||
| 76 | 103 | ||
| 77 | cipher = mt76x02_mac_get_key_info(key, key_data); | 104 | cipher = mt76x02_mac_get_key_info(key, key_data); |
| 78 | if (cipher == MT_CIPHER_NONE && key) | 105 | if (cipher == MT_CIPHER_NONE && key) |
| @@ -85,9 +112,22 @@ int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, | |||
| 85 | if (key) { | 112 | if (key) { |
| 86 | mt76_rmw_field(dev, MT_WCID_ATTR(idx), MT_WCID_ATTR_PAIRWISE, | 113 | mt76_rmw_field(dev, MT_WCID_ATTR(idx), MT_WCID_ATTR_PAIRWISE, |
| 87 | !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)); | 114 | !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)); |
| 115 | |||
| 116 | pn = atomic64_read(&key->tx_pn); | ||
| 117 | |||
| 88 | iv_data[3] = key->keyidx << 6; | 118 | iv_data[3] = key->keyidx << 6; |
| 89 | if (cipher >= MT_CIPHER_TKIP) | 119 | if (cipher >= MT_CIPHER_TKIP) { |
| 90 | iv_data[3] |= 0x20; | 120 | iv_data[3] |= 0x20; |
| 121 | put_unaligned_le32(pn >> 16, &iv_data[4]); | ||
| 122 | } | ||
| 123 | |||
| 124 | if (cipher == MT_CIPHER_TKIP) { | ||
| 125 | iv_data[0] = (pn >> 8) & 0xff; | ||
| 126 | iv_data[1] = (iv_data[0] | 0x20) & 0x7f; | ||
| 127 | iv_data[2] = pn & 0xff; | ||
| 128 | } else if (cipher >= MT_CIPHER_AES_CCMP) { | ||
| 129 | put_unaligned_le16((pn & 0xffff), &iv_data[0]); | ||
| 130 | } | ||
| 91 | } | 131 | } |
| 92 | 132 | ||
| 93 | mt76_wr_copy(dev, MT_WCID_IV(idx), iv_data, sizeof(iv_data)); | 133 | mt76_wr_copy(dev, MT_WCID_IV(idx), iv_data, sizeof(iv_data)); |
| @@ -920,6 +960,7 @@ void mt76x02_edcca_init(struct mt76x02_dev *dev, bool enable) | |||
| 920 | } | 960 | } |
| 921 | } | 961 | } |
| 922 | mt76x02_edcca_tx_enable(dev, true); | 962 | mt76x02_edcca_tx_enable(dev, true); |
| 963 | dev->ed_monitor_learning = true; | ||
| 923 | 964 | ||
| 924 | /* clear previous CCA timer value */ | 965 | /* clear previous CCA timer value */ |
| 925 | mt76_rr(dev, MT_ED_CCA_TIMER); | 966 | mt76_rr(dev, MT_ED_CCA_TIMER); |
| @@ -929,6 +970,10 @@ EXPORT_SYMBOL_GPL(mt76x02_edcca_init); | |||
| 929 | 970 | ||
| 930 | #define MT_EDCCA_TH 92 | 971 | #define MT_EDCCA_TH 92 |
| 931 | #define MT_EDCCA_BLOCK_TH 2 | 972 | #define MT_EDCCA_BLOCK_TH 2 |
| 973 | #define MT_EDCCA_LEARN_TH 50 | ||
| 974 | #define MT_EDCCA_LEARN_CCA 180 | ||
| 975 | #define MT_EDCCA_LEARN_TIMEOUT (20 * HZ) | ||
| 976 | |||
| 932 | static void mt76x02_edcca_check(struct mt76x02_dev *dev) | 977 | static void mt76x02_edcca_check(struct mt76x02_dev *dev) |
| 933 | { | 978 | { |
| 934 | ktime_t cur_time; | 979 | ktime_t cur_time; |
| @@ -951,11 +996,23 @@ static void mt76x02_edcca_check(struct mt76x02_dev *dev) | |||
| 951 | dev->ed_trigger = 0; | 996 | dev->ed_trigger = 0; |
| 952 | } | 997 | } |
| 953 | 998 | ||
| 954 | if (dev->ed_trigger > MT_EDCCA_BLOCK_TH && | 999 | if (dev->cal.agc_lowest_gain && |
| 955 | !dev->ed_tx_blocked) | 1000 | dev->cal.false_cca > MT_EDCCA_LEARN_CCA && |
| 1001 | dev->ed_trigger > MT_EDCCA_LEARN_TH) { | ||
| 1002 | dev->ed_monitor_learning = false; | ||
| 1003 | dev->ed_trigger_timeout = jiffies + 20 * HZ; | ||
| 1004 | } else if (!dev->ed_monitor_learning && | ||
| 1005 | time_is_after_jiffies(dev->ed_trigger_timeout)) { | ||
| 1006 | dev->ed_monitor_learning = true; | ||
| 1007 | mt76x02_edcca_tx_enable(dev, true); | ||
| 1008 | } | ||
| 1009 | |||
| 1010 | if (dev->ed_monitor_learning) | ||
| 1011 | return; | ||
| 1012 | |||
| 1013 | if (dev->ed_trigger > MT_EDCCA_BLOCK_TH && !dev->ed_tx_blocked) | ||
| 956 | mt76x02_edcca_tx_enable(dev, false); | 1014 | mt76x02_edcca_tx_enable(dev, false); |
| 957 | else if (dev->ed_silent > MT_EDCCA_BLOCK_TH && | 1015 | else if (dev->ed_silent > MT_EDCCA_BLOCK_TH && dev->ed_tx_blocked) |
| 958 | dev->ed_tx_blocked) | ||
| 959 | mt76x02_edcca_tx_enable(dev, true); | 1016 | mt76x02_edcca_tx_enable(dev, true); |
| 960 | } | 1017 | } |
| 961 | 1018 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h index 6b1f25d2f64c..caeeef96c42f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h | |||
| @@ -177,6 +177,8 @@ int mt76x02_mac_shared_key_setup(struct mt76x02_dev *dev, u8 vif_idx, | |||
| 177 | u8 key_idx, struct ieee80211_key_conf *key); | 177 | u8 key_idx, struct ieee80211_key_conf *key); |
| 178 | int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, | 178 | int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, |
| 179 | struct ieee80211_key_conf *key); | 179 | struct ieee80211_key_conf *key); |
| 180 | void mt76x02_mac_wcid_sync_pn(struct mt76x02_dev *dev, u8 idx, | ||
| 181 | struct ieee80211_key_conf *key); | ||
| 180 | void mt76x02_mac_wcid_setup(struct mt76x02_dev *dev, u8 idx, u8 vif_idx, | 182 | void mt76x02_mac_wcid_setup(struct mt76x02_dev *dev, u8 idx, u8 vif_idx, |
| 181 | u8 *mac); | 183 | u8 *mac); |
| 182 | void mt76x02_mac_wcid_set_drop(struct mt76x02_dev *dev, u8 idx, bool drop); | 184 | void mt76x02_mac_wcid_set_drop(struct mt76x02_dev *dev, u8 idx, bool drop); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c index 1229f19f2b02..daaed1220147 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/irq.h> | 19 | #include <linux/irq.h> |
| 20 | 20 | ||
| 21 | #include "mt76x02.h" | 21 | #include "mt76x02.h" |
| 22 | #include "mt76x02_mcu.h" | ||
| 22 | #include "mt76x02_trace.h" | 23 | #include "mt76x02_trace.h" |
| 23 | 24 | ||
| 24 | struct beacon_bc_data { | 25 | struct beacon_bc_data { |
| @@ -418,9 +419,66 @@ static bool mt76x02_tx_hang(struct mt76x02_dev *dev) | |||
| 418 | return i < 4; | 419 | return i < 4; |
| 419 | } | 420 | } |
| 420 | 421 | ||
| 422 | static void mt76x02_key_sync(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | ||
| 423 | struct ieee80211_sta *sta, | ||
| 424 | struct ieee80211_key_conf *key, void *data) | ||
| 425 | { | ||
| 426 | struct mt76x02_dev *dev = hw->priv; | ||
| 427 | struct mt76_wcid *wcid; | ||
| 428 | |||
| 429 | if (!sta) | ||
| 430 | return; | ||
| 431 | |||
| 432 | wcid = (struct mt76_wcid *) sta->drv_priv; | ||
| 433 | |||
| 434 | if (wcid->hw_key_idx != key->keyidx || wcid->sw_iv) | ||
| 435 | return; | ||
| 436 | |||
| 437 | mt76x02_mac_wcid_sync_pn(dev, wcid->idx, key); | ||
| 438 | } | ||
| 439 | |||
| 440 | static void mt76x02_reset_state(struct mt76x02_dev *dev) | ||
| 441 | { | ||
| 442 | int i; | ||
| 443 | |||
| 444 | lockdep_assert_held(&dev->mt76.mutex); | ||
| 445 | |||
| 446 | clear_bit(MT76_STATE_RUNNING, &dev->mt76.state); | ||
| 447 | |||
| 448 | rcu_read_lock(); | ||
| 449 | ieee80211_iter_keys_rcu(dev->mt76.hw, NULL, mt76x02_key_sync, NULL); | ||
| 450 | rcu_read_unlock(); | ||
| 451 | |||
| 452 | for (i = 0; i < ARRAY_SIZE(dev->mt76.wcid); i++) { | ||
| 453 | struct ieee80211_sta *sta; | ||
| 454 | struct ieee80211_vif *vif; | ||
| 455 | struct mt76x02_sta *msta; | ||
| 456 | struct mt76_wcid *wcid; | ||
| 457 | void *priv; | ||
| 458 | |||
| 459 | wcid = rcu_dereference_protected(dev->mt76.wcid[i], | ||
| 460 | lockdep_is_held(&dev->mt76.mutex)); | ||
| 461 | if (!wcid) | ||
| 462 | continue; | ||
| 463 | |||
| 464 | priv = msta = container_of(wcid, struct mt76x02_sta, wcid); | ||
| 465 | sta = container_of(priv, struct ieee80211_sta, drv_priv); | ||
| 466 | |||
| 467 | priv = msta->vif; | ||
| 468 | vif = container_of(priv, struct ieee80211_vif, drv_priv); | ||
| 469 | |||
| 470 | __mt76_sta_remove(&dev->mt76, vif, sta); | ||
| 471 | memset(msta, 0, sizeof(*msta)); | ||
| 472 | } | ||
| 473 | |||
| 474 | dev->vif_mask = 0; | ||
| 475 | dev->beacon_mask = 0; | ||
| 476 | } | ||
| 477 | |||
| 421 | static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) | 478 | static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) |
| 422 | { | 479 | { |
| 423 | u32 mask = dev->mt76.mmio.irqmask; | 480 | u32 mask = dev->mt76.mmio.irqmask; |
| 481 | bool restart = dev->mt76.mcu_ops->mcu_restart; | ||
| 424 | int i; | 482 | int i; |
| 425 | 483 | ||
| 426 | ieee80211_stop_queues(dev->mt76.hw); | 484 | ieee80211_stop_queues(dev->mt76.hw); |
| @@ -434,6 +492,9 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) | |||
| 434 | 492 | ||
| 435 | mutex_lock(&dev->mt76.mutex); | 493 | mutex_lock(&dev->mt76.mutex); |
| 436 | 494 | ||
| 495 | if (restart) | ||
| 496 | mt76x02_reset_state(dev); | ||
| 497 | |||
| 437 | if (dev->beacon_mask) | 498 | if (dev->beacon_mask) |
| 438 | mt76_clear(dev, MT_BEACON_TIME_CFG, | 499 | mt76_clear(dev, MT_BEACON_TIME_CFG, |
| 439 | MT_BEACON_TIME_CFG_BEACON_TX | | 500 | MT_BEACON_TIME_CFG_BEACON_TX | |
| @@ -452,20 +513,21 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) | |||
| 452 | /* let fw reset DMA */ | 513 | /* let fw reset DMA */ |
| 453 | mt76_set(dev, 0x734, 0x3); | 514 | mt76_set(dev, 0x734, 0x3); |
| 454 | 515 | ||
| 516 | if (restart) | ||
| 517 | dev->mt76.mcu_ops->mcu_restart(&dev->mt76); | ||
| 518 | |||
| 455 | for (i = 0; i < ARRAY_SIZE(dev->mt76.q_tx); i++) | 519 | for (i = 0; i < ARRAY_SIZE(dev->mt76.q_tx); i++) |
| 456 | mt76_queue_tx_cleanup(dev, i, true); | 520 | mt76_queue_tx_cleanup(dev, i, true); |
| 457 | 521 | ||
| 458 | for (i = 0; i < ARRAY_SIZE(dev->mt76.q_rx); i++) | 522 | for (i = 0; i < ARRAY_SIZE(dev->mt76.q_rx); i++) |
| 459 | mt76_queue_rx_reset(dev, i); | 523 | mt76_queue_rx_reset(dev, i); |
| 460 | 524 | ||
| 461 | mt76_wr(dev, MT_MAC_SYS_CTRL, | 525 | mt76x02_mac_start(dev); |
| 462 | MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX); | 526 | |
| 463 | mt76_set(dev, MT_WPDMA_GLO_CFG, | ||
| 464 | MT_WPDMA_GLO_CFG_TX_DMA_EN | MT_WPDMA_GLO_CFG_RX_DMA_EN); | ||
| 465 | if (dev->ed_monitor) | 527 | if (dev->ed_monitor) |
| 466 | mt76_set(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN); | 528 | mt76_set(dev, MT_TXOP_CTRL_CFG, MT_TXOP_ED_CCA_EN); |
| 467 | 529 | ||
| 468 | if (dev->beacon_mask) | 530 | if (dev->beacon_mask && !restart) |
| 469 | mt76_set(dev, MT_BEACON_TIME_CFG, | 531 | mt76_set(dev, MT_BEACON_TIME_CFG, |
| 470 | MT_BEACON_TIME_CFG_BEACON_TX | | 532 | MT_BEACON_TIME_CFG_BEACON_TX | |
| 471 | MT_BEACON_TIME_CFG_TBTT_EN); | 533 | MT_BEACON_TIME_CFG_TBTT_EN); |
| @@ -486,9 +548,13 @@ static void mt76x02_watchdog_reset(struct mt76x02_dev *dev) | |||
| 486 | napi_schedule(&dev->mt76.napi[i]); | 548 | napi_schedule(&dev->mt76.napi[i]); |
| 487 | } | 549 | } |
| 488 | 550 | ||
| 489 | ieee80211_wake_queues(dev->mt76.hw); | 551 | if (restart) { |
| 490 | 552 | mt76x02_mcu_function_select(dev, Q_SELECT, 1); | |
| 491 | mt76_txq_schedule_all(&dev->mt76); | 553 | ieee80211_restart_hw(dev->mt76.hw); |
| 554 | } else { | ||
| 555 | ieee80211_wake_queues(dev->mt76.hw); | ||
| 556 | mt76_txq_schedule_all(&dev->mt76); | ||
| 557 | } | ||
| 492 | } | 558 | } |
| 493 | 559 | ||
| 494 | static void mt76x02_check_tx_hang(struct mt76x02_dev *dev) | 560 | static void mt76x02_check_tx_hang(struct mt76x02_dev *dev) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c index a020c757ba5c..a54b63a96eae 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | |||
| @@ -194,6 +194,8 @@ bool mt76x02_phy_adjust_vga_gain(struct mt76x02_dev *dev) | |||
| 194 | ret = true; | 194 | ret = true; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | dev->cal.agc_lowest_gain = dev->cal.agc_gain_adjust >= limit; | ||
| 198 | |||
| 197 | return ret; | 199 | return ret; |
| 198 | } | 200 | } |
| 199 | EXPORT_SYMBOL_GPL(mt76x02_phy_adjust_vga_gain); | 201 | EXPORT_SYMBOL_GPL(mt76x02_phy_adjust_vga_gain); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c index 43f07461c8d3..6fb52b596d42 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c | |||
| @@ -85,8 +85,9 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data, | |||
| 85 | 85 | ||
| 86 | mt76x02_insert_hdr_pad(skb); | 86 | mt76x02_insert_hdr_pad(skb); |
| 87 | 87 | ||
| 88 | txwi = skb_push(skb, sizeof(struct mt76x02_txwi)); | 88 | txwi = (struct mt76x02_txwi *)(skb->data - sizeof(struct mt76x02_txwi)); |
| 89 | mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, len); | 89 | mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, len); |
| 90 | skb_push(skb, sizeof(struct mt76x02_txwi)); | ||
| 90 | 91 | ||
| 91 | pid = mt76_tx_status_skb_add(mdev, wcid, skb); | 92 | pid = mt76_tx_status_skb_add(mdev, wcid, skb); |
| 92 | txwi->pktid = pid; | 93 | txwi->pktid = pid; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c index a48c261b0c63..cd072ac614f7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c | |||
| @@ -237,6 +237,8 @@ int mt76x02_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, | |||
| 237 | struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; | 237 | struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; |
| 238 | int idx = 0; | 238 | int idx = 0; |
| 239 | 239 | ||
| 240 | memset(msta, 0, sizeof(*msta)); | ||
| 241 | |||
| 240 | idx = mt76_wcid_alloc(dev->mt76.wcid_mask, ARRAY_SIZE(dev->mt76.wcid)); | 242 | idx = mt76_wcid_alloc(dev->mt76.wcid_mask, ARRAY_SIZE(dev->mt76.wcid)); |
| 241 | if (idx < 0) | 243 | if (idx < 0) |
| 242 | return -ENOSPC; | 244 | return -ENOSPC; |
| @@ -274,6 +276,8 @@ mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif, | |||
| 274 | struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; | 276 | struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv; |
| 275 | struct mt76_txq *mtxq; | 277 | struct mt76_txq *mtxq; |
| 276 | 278 | ||
| 279 | memset(mvif, 0, sizeof(*mvif)); | ||
| 280 | |||
| 277 | mvif->idx = idx; | 281 | mvif->idx = idx; |
| 278 | mvif->group_wcid.idx = MT_VIF_WCID(idx); | 282 | mvif->group_wcid.idx = MT_VIF_WCID(idx); |
| 279 | mvif->group_wcid.hw_key_idx = -1; | 283 | mvif->group_wcid.hw_key_idx = -1; |
| @@ -289,6 +293,12 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | |||
| 289 | struct mt76x02_dev *dev = hw->priv; | 293 | struct mt76x02_dev *dev = hw->priv; |
| 290 | unsigned int idx = 0; | 294 | unsigned int idx = 0; |
| 291 | 295 | ||
| 296 | /* Allow to change address in HW if we create first interface. */ | ||
| 297 | if (!dev->vif_mask && | ||
| 298 | (((vif->addr[0] ^ dev->mt76.macaddr[0]) & ~GENMASK(4, 1)) || | ||
| 299 | memcmp(vif->addr + 1, dev->mt76.macaddr + 1, ETH_ALEN - 1))) | ||
| 300 | mt76x02_mac_setaddr(dev, vif->addr); | ||
| 301 | |||
| 292 | if (vif->addr[0] & BIT(1)) | 302 | if (vif->addr[0] & BIT(1)) |
| 293 | idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7); | 303 | idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7); |
| 294 | 304 | ||
| @@ -311,10 +321,6 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | |||
| 311 | if (dev->vif_mask & BIT(idx)) | 321 | if (dev->vif_mask & BIT(idx)) |
| 312 | return -EBUSY; | 322 | return -EBUSY; |
| 313 | 323 | ||
| 314 | /* Allow to change address in HW if we create first interface. */ | ||
| 315 | if (!dev->vif_mask && !ether_addr_equal(dev->mt76.macaddr, vif->addr)) | ||
| 316 | mt76x02_mac_setaddr(dev, vif->addr); | ||
| 317 | |||
| 318 | dev->vif_mask |= BIT(idx); | 324 | dev->vif_mask |= BIT(idx); |
| 319 | 325 | ||
| 320 | mt76x02_vif_init(dev, vif, idx); | 326 | mt76x02_vif_init(dev, vif, idx); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/init.c index f8534362e2c8..a30ef2c5a9db 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/init.c | |||
| @@ -106,7 +106,7 @@ void mt76_write_mac_initvals(struct mt76x02_dev *dev) | |||
| 106 | { MT_TX_SW_CFG1, 0x00010000 }, | 106 | { MT_TX_SW_CFG1, 0x00010000 }, |
| 107 | { MT_TX_SW_CFG2, 0x00000000 }, | 107 | { MT_TX_SW_CFG2, 0x00000000 }, |
| 108 | { MT_TXOP_CTRL_CFG, 0x0400583f }, | 108 | { MT_TXOP_CTRL_CFG, 0x0400583f }, |
| 109 | { MT_TX_RTS_CFG, 0x00100020 }, | 109 | { MT_TX_RTS_CFG, 0x00ffff20 }, |
| 110 | { MT_TX_TIMEOUT_CFG, 0x000a2290 }, | 110 | { MT_TX_TIMEOUT_CFG, 0x000a2290 }, |
| 111 | { MT_TX_RETRY_CFG, 0x47f01f0f }, | 111 | { MT_TX_RETRY_CFG, 0x47f01f0f }, |
| 112 | { MT_EXP_ACK_TIME, 0x002c00dc }, | 112 | { MT_EXP_ACK_TIME, 0x002c00dc }, |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h index 6c619f1c65c9..d7abe3d73bad 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h | |||
| @@ -71,6 +71,7 @@ int mt76x2_mcu_load_cr(struct mt76x02_dev *dev, u8 type, u8 temp_level, | |||
| 71 | 71 | ||
| 72 | void mt76x2_cleanup(struct mt76x02_dev *dev); | 72 | void mt76x2_cleanup(struct mt76x02_dev *dev); |
| 73 | 73 | ||
| 74 | int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard); | ||
| 74 | void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable); | 75 | void mt76x2_reset_wlan(struct mt76x02_dev *dev, bool enable); |
| 75 | void mt76x2_init_txpower(struct mt76x02_dev *dev, | 76 | void mt76x2_init_txpower(struct mt76x02_dev *dev, |
| 76 | struct ieee80211_supported_band *sband); | 77 | struct ieee80211_supported_band *sband); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c index 984d9c4c2e1a..d3927a13e92e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c | |||
| @@ -77,7 +77,7 @@ mt76x2_fixup_xtal(struct mt76x02_dev *dev) | |||
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard) | 80 | int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard) |
| 81 | { | 81 | { |
| 82 | const u8 *macaddr = dev->mt76.macaddr; | 82 | const u8 *macaddr = dev->mt76.macaddr; |
| 83 | u32 val; | 83 | u32 val; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c index 03e24ae7f66c..605dc66ae83b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c | |||
| @@ -165,9 +165,30 @@ error: | |||
| 165 | return -ENOENT; | 165 | return -ENOENT; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | static int | ||
| 169 | mt76pci_mcu_restart(struct mt76_dev *mdev) | ||
| 170 | { | ||
| 171 | struct mt76x02_dev *dev; | ||
| 172 | int ret; | ||
| 173 | |||
| 174 | dev = container_of(mdev, struct mt76x02_dev, mt76); | ||
| 175 | |||
| 176 | mt76x02_mcu_cleanup(dev); | ||
| 177 | mt76x2_mac_reset(dev, true); | ||
| 178 | |||
| 179 | ret = mt76pci_load_firmware(dev); | ||
| 180 | if (ret) | ||
| 181 | return ret; | ||
| 182 | |||
| 183 | mt76_wr(dev, MT_WPDMA_RST_IDX, ~0); | ||
| 184 | |||
| 185 | return 0; | ||
| 186 | } | ||
| 187 | |||
| 168 | int mt76x2_mcu_init(struct mt76x02_dev *dev) | 188 | int mt76x2_mcu_init(struct mt76x02_dev *dev) |
| 169 | { | 189 | { |
| 170 | static const struct mt76_mcu_ops mt76x2_mcu_ops = { | 190 | static const struct mt76_mcu_ops mt76x2_mcu_ops = { |
| 191 | .mcu_restart = mt76pci_mcu_restart, | ||
| 171 | .mcu_send_msg = mt76x02_mcu_msg_send, | 192 | .mcu_send_msg = mt76x02_mcu_msg_send, |
| 172 | }; | 193 | }; |
| 173 | int ret; | 194 | int ret; |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c index 1848e8ab2e21..769a9b972044 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c | |||
| @@ -260,10 +260,15 @@ mt76x2_phy_set_gain_val(struct mt76x02_dev *dev) | |||
| 260 | gain_val[0] = dev->cal.agc_gain_cur[0] - dev->cal.agc_gain_adjust; | 260 | gain_val[0] = dev->cal.agc_gain_cur[0] - dev->cal.agc_gain_adjust; |
| 261 | gain_val[1] = dev->cal.agc_gain_cur[1] - dev->cal.agc_gain_adjust; | 261 | gain_val[1] = dev->cal.agc_gain_cur[1] - dev->cal.agc_gain_adjust; |
| 262 | 262 | ||
| 263 | if (dev->mt76.chandef.width >= NL80211_CHAN_WIDTH_40) | 263 | val = 0x1836 << 16; |
| 264 | if (!mt76x2_has_ext_lna(dev) && | ||
| 265 | dev->mt76.chandef.width >= NL80211_CHAN_WIDTH_40) | ||
| 264 | val = 0x1e42 << 16; | 266 | val = 0x1e42 << 16; |
| 265 | else | 267 | |
| 266 | val = 0x1836 << 16; | 268 | if (mt76x2_has_ext_lna(dev) && |
| 269 | dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ && | ||
| 270 | dev->mt76.chandef.width < NL80211_CHAN_WIDTH_40) | ||
| 271 | val = 0x0f36 << 16; | ||
| 267 | 272 | ||
| 268 | val |= 0xf8; | 273 | val |= 0xf8; |
| 269 | 274 | ||
| @@ -280,6 +285,7 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) | |||
| 280 | { | 285 | { |
| 281 | u8 *gain = dev->cal.agc_gain_init; | 286 | u8 *gain = dev->cal.agc_gain_init; |
| 282 | u8 low_gain_delta, gain_delta; | 287 | u8 low_gain_delta, gain_delta; |
| 288 | u32 agc_35, agc_37; | ||
| 283 | bool gain_change; | 289 | bool gain_change; |
| 284 | int low_gain; | 290 | int low_gain; |
| 285 | u32 val; | 291 | u32 val; |
| @@ -318,6 +324,16 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) | |||
| 318 | else | 324 | else |
| 319 | low_gain_delta = 14; | 325 | low_gain_delta = 14; |
| 320 | 326 | ||
| 327 | agc_37 = 0x2121262c; | ||
| 328 | if (dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ) | ||
| 329 | agc_35 = 0x11111516; | ||
| 330 | else if (low_gain == 2) | ||
| 331 | agc_35 = agc_37 = 0x08080808; | ||
| 332 | else if (dev->mt76.chandef.width == NL80211_CHAN_WIDTH_80) | ||
| 333 | agc_35 = 0x10101014; | ||
| 334 | else | ||
| 335 | agc_35 = 0x11111116; | ||
| 336 | |||
| 321 | if (low_gain == 2) { | 337 | if (low_gain == 2) { |
| 322 | mt76_wr(dev, MT_BBP(RXO, 18), 0xf000a990); | 338 | mt76_wr(dev, MT_BBP(RXO, 18), 0xf000a990); |
| 323 | mt76_wr(dev, MT_BBP(AGC, 35), 0x08080808); | 339 | mt76_wr(dev, MT_BBP(AGC, 35), 0x08080808); |
| @@ -326,15 +342,13 @@ void mt76x2_phy_update_channel_gain(struct mt76x02_dev *dev) | |||
| 326 | dev->cal.agc_gain_adjust = 0; | 342 | dev->cal.agc_gain_adjust = 0; |
| 327 | } else { | 343 | } else { |
| 328 | mt76_wr(dev, MT_BBP(RXO, 18), 0xf000a991); | 344 | mt76_wr(dev, MT_BBP(RXO, 18), 0xf000a991); |
| 329 | if (dev->mt76.chandef.width == NL80211_CHAN_WIDTH_80) | ||
| 330 | mt76_wr(dev, MT_BBP(AGC, 35), 0x10101014); | ||
| 331 | else | ||
| 332 | mt76_wr(dev, MT_BBP(AGC, 35), 0x11111116); | ||
| 333 | mt76_wr(dev, MT_BBP(AGC, 37), 0x2121262C); | ||
| 334 | gain_delta = 0; | 345 | gain_delta = 0; |
| 335 | dev->cal.agc_gain_adjust = low_gain_delta; | 346 | dev->cal.agc_gain_adjust = low_gain_delta; |
| 336 | } | 347 | } |
| 337 | 348 | ||
| 349 | mt76_wr(dev, MT_BBP(AGC, 35), agc_35); | ||
| 350 | mt76_wr(dev, MT_BBP(AGC, 37), agc_37); | ||
| 351 | |||
| 338 | dev->cal.agc_gain_cur[0] = gain[0] - gain_delta; | 352 | dev->cal.agc_gain_cur[0] = gain[0] - gain_delta; |
| 339 | dev->cal.agc_gain_cur[1] = gain[1] - gain_delta; | 353 | dev->cal.agc_gain_cur[1] = gain[1] - gain_delta; |
| 340 | mt76x2_phy_set_gain_val(dev); | 354 | mt76x2_phy_set_gain_val(dev); |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c index ddb6b2c48e01..ac0f13d46299 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb.c | |||
| @@ -21,11 +21,10 @@ | |||
| 21 | #include "mt76x2u.h" | 21 | #include "mt76x2u.h" |
| 22 | 22 | ||
| 23 | static const struct usb_device_id mt76x2u_device_table[] = { | 23 | static const struct usb_device_id mt76x2u_device_table[] = { |
| 24 | { USB_DEVICE(0x0e8d, 0x7612) }, /* Alfa AWUS036ACM */ | ||
| 25 | { USB_DEVICE(0x0b05, 0x1833) }, /* Asus USB-AC54 */ | 24 | { USB_DEVICE(0x0b05, 0x1833) }, /* Asus USB-AC54 */ |
| 26 | { USB_DEVICE(0x0b05, 0x17eb) }, /* Asus USB-AC55 */ | 25 | { USB_DEVICE(0x0b05, 0x17eb) }, /* Asus USB-AC55 */ |
| 27 | { USB_DEVICE(0x0b05, 0x180b) }, /* Asus USB-N53 B1 */ | 26 | { USB_DEVICE(0x0b05, 0x180b) }, /* Asus USB-N53 B1 */ |
| 28 | { USB_DEVICE(0x0e8d, 0x7612) }, /* Aukey USB-AC1200 */ | 27 | { USB_DEVICE(0x0e8d, 0x7612) }, /* Aukey USBAC1200 - Alfa AWUS036ACM */ |
| 29 | { USB_DEVICE(0x057c, 0x8503) }, /* Avm FRITZ!WLAN AC860 */ | 28 | { USB_DEVICE(0x057c, 0x8503) }, /* Avm FRITZ!WLAN AC860 */ |
| 30 | { USB_DEVICE(0x7392, 0xb711) }, /* Edimax EW 7722 UAC */ | 29 | { USB_DEVICE(0x7392, 0xb711) }, /* Edimax EW 7722 UAC */ |
| 31 | { USB_DEVICE(0x0846, 0x9053) }, /* Netgear A6210 */ | 30 | { USB_DEVICE(0x0846, 0x9053) }, /* Netgear A6210 */ |
| @@ -66,6 +65,10 @@ static int mt76x2u_probe(struct usb_interface *intf, | |||
| 66 | 65 | ||
| 67 | mdev->rev = mt76_rr(dev, MT_ASIC_VERSION); | 66 | mdev->rev = mt76_rr(dev, MT_ASIC_VERSION); |
| 68 | dev_info(mdev->dev, "ASIC revision: %08x\n", mdev->rev); | 67 | dev_info(mdev->dev, "ASIC revision: %08x\n", mdev->rev); |
| 68 | if (!is_mt76x2(dev)) { | ||
| 69 | err = -ENODEV; | ||
| 70 | goto err; | ||
| 71 | } | ||
| 69 | 72 | ||
| 70 | err = mt76x2u_register_device(dev); | 73 | err = mt76x2u_register_device(dev); |
| 71 | if (err < 0) | 74 | if (err < 0) |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c index 5e84b4535cb1..3b82345756ea 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c | |||
| @@ -93,7 +93,6 @@ int mt76x2u_mac_reset(struct mt76x02_dev *dev) | |||
| 93 | mt76_wr(dev, MT_TX_LINK_CFG, 0x1020); | 93 | mt76_wr(dev, MT_TX_LINK_CFG, 0x1020); |
| 94 | mt76_wr(dev, MT_AUTO_RSP_CFG, 0x13); | 94 | mt76_wr(dev, MT_AUTO_RSP_CFG, 0x13); |
| 95 | mt76_wr(dev, MT_MAX_LEN_CFG, 0x2f00); | 95 | mt76_wr(dev, MT_MAX_LEN_CFG, 0x2f00); |
| 96 | mt76_wr(dev, MT_TX_RTS_CFG, 0x92b20); | ||
| 97 | 96 | ||
| 98 | mt76_wr(dev, MT_WMM_AIFSN, 0x2273); | 97 | mt76_wr(dev, MT_WMM_AIFSN, 0x2273); |
| 99 | mt76_wr(dev, MT_WMM_CWMIN, 0x2344); | 98 | mt76_wr(dev, MT_WMM_CWMIN, 0x2344); |
diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c index 5a349fe3e576..2585df512335 100644 --- a/drivers/net/wireless/mediatek/mt76/tx.c +++ b/drivers/net/wireless/mediatek/mt76/tx.c | |||
| @@ -289,8 +289,11 @@ mt76_tx(struct mt76_dev *dev, struct ieee80211_sta *sta, | |||
| 289 | dev->queue_ops->tx_queue_skb(dev, q, skb, wcid, sta); | 289 | dev->queue_ops->tx_queue_skb(dev, q, skb, wcid, sta); |
| 290 | dev->queue_ops->kick(dev, q); | 290 | dev->queue_ops->kick(dev, q); |
| 291 | 291 | ||
| 292 | if (q->queued > q->ndesc - 8) | 292 | if (q->queued > q->ndesc - 8 && !q->stopped) { |
| 293 | ieee80211_stop_queue(dev->hw, skb_get_queue_mapping(skb)); | 293 | ieee80211_stop_queue(dev->hw, skb_get_queue_mapping(skb)); |
| 294 | q->stopped = true; | ||
| 295 | } | ||
| 296 | |||
| 294 | spin_unlock_bh(&q->lock); | 297 | spin_unlock_bh(&q->lock); |
| 295 | } | 298 | } |
| 296 | EXPORT_SYMBOL_GPL(mt76_tx); | 299 | EXPORT_SYMBOL_GPL(mt76_tx); |
| @@ -374,7 +377,10 @@ mt76_release_buffered_frames(struct ieee80211_hw *hw, struct ieee80211_sta *sta, | |||
| 374 | if (last_skb) { | 377 | if (last_skb) { |
| 375 | mt76_queue_ps_skb(dev, sta, last_skb, true); | 378 | mt76_queue_ps_skb(dev, sta, last_skb, true); |
| 376 | dev->queue_ops->kick(dev, hwq); | 379 | dev->queue_ops->kick(dev, hwq); |
| 380 | } else { | ||
| 381 | ieee80211_sta_eosp(sta); | ||
| 377 | } | 382 | } |
| 383 | |||
| 378 | spin_unlock_bh(&hwq->lock); | 384 | spin_unlock_bh(&hwq->lock); |
| 379 | } | 385 | } |
| 380 | EXPORT_SYMBOL_GPL(mt76_release_buffered_frames); | 386 | EXPORT_SYMBOL_GPL(mt76_release_buffered_frames); |
| @@ -577,6 +583,9 @@ void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq) | |||
| 577 | struct mt76_txq *mtxq = (struct mt76_txq *) txq->drv_priv; | 583 | struct mt76_txq *mtxq = (struct mt76_txq *) txq->drv_priv; |
| 578 | struct mt76_queue *hwq = mtxq->hwq; | 584 | struct mt76_queue *hwq = mtxq->hwq; |
| 579 | 585 | ||
| 586 | if (!test_bit(MT76_STATE_RUNNING, &dev->state)) | ||
| 587 | return; | ||
| 588 | |||
| 580 | spin_lock_bh(&hwq->lock); | 589 | spin_lock_bh(&hwq->lock); |
| 581 | if (list_empty(&mtxq->list)) | 590 | if (list_empty(&mtxq->list)) |
| 582 | list_add_tail(&mtxq->list, &hwq->swq); | 591 | list_add_tail(&mtxq->list, &hwq->swq); |
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index ae6ada370597..4c1abd492405 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c | |||
| @@ -655,7 +655,11 @@ static void mt76u_tx_tasklet(unsigned long data) | |||
| 655 | spin_lock_bh(&q->lock); | 655 | spin_lock_bh(&q->lock); |
| 656 | } | 656 | } |
| 657 | mt76_txq_schedule(dev, q); | 657 | mt76_txq_schedule(dev, q); |
| 658 | wake = i < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8; | 658 | |
| 659 | wake = q->stopped && q->queued < q->ndesc - 8; | ||
| 660 | if (wake) | ||
| 661 | q->stopped = false; | ||
| 662 | |||
| 659 | if (!q->queued) | 663 | if (!q->queued) |
| 660 | wake_up(&dev->tx_wait); | 664 | wake_up(&dev->tx_wait); |
| 661 | 665 | ||
diff --git a/drivers/net/wireless/mediatek/mt7601u/usb.c b/drivers/net/wireless/mediatek/mt7601u/usb.c index d8b7863f7926..6ae7f14dc9bf 100644 --- a/drivers/net/wireless/mediatek/mt7601u/usb.c +++ b/drivers/net/wireless/mediatek/mt7601u/usb.c | |||
| @@ -303,6 +303,10 @@ static int mt7601u_probe(struct usb_interface *usb_intf, | |||
| 303 | mac_rev = mt7601u_rr(dev, MT_MAC_CSR0); | 303 | mac_rev = mt7601u_rr(dev, MT_MAC_CSR0); |
| 304 | dev_info(dev->dev, "ASIC revision: %08x MAC revision: %08x\n", | 304 | dev_info(dev->dev, "ASIC revision: %08x MAC revision: %08x\n", |
| 305 | asic_rev, mac_rev); | 305 | asic_rev, mac_rev); |
| 306 | if ((asic_rev >> 16) != 0x7601) { | ||
| 307 | ret = -ENODEV; | ||
| 308 | goto err; | ||
| 309 | } | ||
| 306 | 310 | ||
| 307 | /* Note: vendor driver skips this check for MT7601U */ | 311 | /* Note: vendor driver skips this check for MT7601U */ |
| 308 | if (!(mt7601u_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) | 312 | if (!(mt7601u_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL)) |
