From 914365f1c97d3aa1881fd6fc477c4799a39c00f9 Mon Sep 17 00:00:00 2001 From: Yan Markman Date: Thu, 17 May 2018 10:34:25 +0200 Subject: [PATCH 1/3] net: mvpp2: avoid checking for free aggregated descriptors twice Avoid repeating the check for free aggregated descriptors when it already failed at the beginning of the function. Signed-off-by: Yan Markman [Antoine: commit message] Signed-off-by: Antoine Tenart Signed-off-by: David S. Miller --- drivers/net/ethernet/marvell/mvpp2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index 5e580482769e..de664b3f45f2 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -5487,11 +5487,10 @@ static int mvpp2_aggr_desc_num_check(struct mvpp2 *priv, MVPP2_AGGR_TXQ_STATUS_REG(cpu)); aggr_txq->count = val & MVPP2_AGGR_TXQ_PENDING_MASK; + + if ((aggr_txq->count + num) > MVPP2_AGGR_TXQ_SIZE) + return -ENOMEM; } - - if ((aggr_txq->count + num) > MVPP2_AGGR_TXQ_SIZE) - return -ENOMEM; - return 0; } From 5b0ab2f41d7593d87762dce1cbaf548f988a2917 Mon Sep 17 00:00:00 2001 From: Yan Markman Date: Thu, 17 May 2018 10:34:26 +0200 Subject: [PATCH 2/3] net: mvpp2: set mac address does not require the stop/start sequence Remove special stop/start handling from the set_mac_address callback. All this special care is not needed, and can be removed. It also simplifies the up/down status in the driver and helps avoiding possible link status mismatch issues. Signed-off-by: Yan Markman [Antoine: commit message] Signed-off-by: Antoine Tenart Signed-off-by: David S. Miller --- drivers/net/ethernet/marvell/mvpp2.c | 38 +++++----------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index de664b3f45f2..8c9496002bd7 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -7357,42 +7357,18 @@ static void mvpp2_set_rx_mode(struct net_device *dev) static int mvpp2_set_mac_address(struct net_device *dev, void *p) { - struct mvpp2_port *port = netdev_priv(dev); const struct sockaddr *addr = p; int err; - if (!is_valid_ether_addr(addr->sa_data)) { - err = -EADDRNOTAVAIL; - goto log_error; - } - - if (!netif_running(dev)) { - err = mvpp2_prs_update_mac_da(dev, addr->sa_data); - if (!err) - return 0; - /* Reconfigure parser to accept the original MAC address */ - err = mvpp2_prs_update_mac_da(dev, dev->dev_addr); - if (err) - goto log_error; - } - - mvpp2_stop_dev(port); + if (!is_valid_ether_addr(addr->sa_data)) + return -EADDRNOTAVAIL; err = mvpp2_prs_update_mac_da(dev, addr->sa_data); - if (!err) - goto out_start; - - /* Reconfigure parser accept the original MAC address */ - err = mvpp2_prs_update_mac_da(dev, dev->dev_addr); - if (err) - goto log_error; -out_start: - mvpp2_start_dev(port); - mvpp2_egress_enable(port); - mvpp2_ingress_enable(port); - return 0; -log_error: - netdev_err(dev, "failed to change MAC address\n"); + if (err) { + /* Reconfigure parser accept the original MAC address */ + mvpp2_prs_update_mac_da(dev, dev->dev_addr); + netdev_err(dev, "failed to change MAC address\n"); + } return err; } From 934e0f8330a483a582805c640ef9885b4e69aa63 Mon Sep 17 00:00:00 2001 From: Yan Markman Date: Thu, 17 May 2018 10:34:27 +0200 Subject: [PATCH 3/3] net: mvpp2: print rx error with rate-limit Prevent flood of RX error prints during heavy traffic with weak signal in link by checking net_ratelimit() before using netdev_err(). Signed-off-by: Yan Markman [Antoine: small rework, commit message] Signed-off-by: Antoine Tenart Signed-off-by: David S. Miller --- drivers/net/ethernet/marvell/mvpp2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index 8c9496002bd7..7ba7e5938c2e 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -6381,21 +6381,23 @@ static void mvpp2_rx_error(struct mvpp2_port *port, { u32 status = mvpp2_rxdesc_status_get(port, rx_desc); size_t sz = mvpp2_rxdesc_size_get(port, rx_desc); + char *err_str = NULL; switch (status & MVPP2_RXD_ERR_CODE_MASK) { case MVPP2_RXD_ERR_CRC: - netdev_err(port->dev, "bad rx status %08x (crc error), size=%zu\n", - status, sz); + err_str = "crc"; break; case MVPP2_RXD_ERR_OVERRUN: - netdev_err(port->dev, "bad rx status %08x (overrun error), size=%zu\n", - status, sz); + err_str = "overrun"; break; case MVPP2_RXD_ERR_RESOURCE: - netdev_err(port->dev, "bad rx status %08x (resource error), size=%zu\n", - status, sz); + err_str = "resource"; break; } + if (err_str && net_ratelimit()) + netdev_err(port->dev, + "bad rx status %08x (%s error), size=%zu\n", + status, err_str, sz); } /* Handle RX checksum offload */