Skip to content

Commit

Permalink
drivers: net: cpsw: dual_emac: simplify napi usage
Browse files Browse the repository at this point in the history
Since interrupt is shared between the two ethernet interface and
in isr only one napi is scheduled at an instance so having two
napis doesn't make any difference. So making napi also as a
common resource for the dual ethernet interfaces.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Mugunthan V N authored and David S. Miller committed Aug 7, 2015
1 parent 870915f commit d354eb8
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions drivers/net/ethernet/ti/cpsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,20 +768,8 @@ static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);
writel(0, &priv->wr_regs->rx_en);

if (netif_running(priv->ndev)) {
napi_schedule(&priv->napi);
return IRQ_HANDLED;
}

priv = cpsw_get_slave_priv(priv, 1);
if (!priv)
return IRQ_NONE;

if (netif_running(priv->ndev)) {
napi_schedule(&priv->napi);
return IRQ_HANDLED;
}
return IRQ_NONE;
napi_schedule(&priv->napi);
return IRQ_HANDLED;
}

static int cpsw_poll(struct napi_struct *napi, int budget)
Expand Down Expand Up @@ -1246,6 +1234,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
ALE_ALL_PORTS << priv->host_port, 0, 0);

if (!cpsw_common_res_usage_state(priv)) {
struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(priv, 0);

/* setup tx dma to fixed prio and zero offset */
cpdma_control_set(priv->dma, CPDMA_TX_PRIO_FIXED, 1);
cpdma_control_set(priv->dma, CPDMA_RX_BUFFER_OFFSET, 0);
Expand All @@ -1259,6 +1249,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
/* Enable internal fifo flow control */
writel(0x7, &priv->regs->flow_control);

napi_enable(&priv_sl0->napi);

if (WARN_ON(!priv->data.rx_descs))
priv->data.rx_descs = 128;

Expand Down Expand Up @@ -1297,7 +1289,6 @@ static int cpsw_ndo_open(struct net_device *ndev)
cpsw_set_coalesce(ndev, &coal);
}

napi_enable(&priv->napi);
cpdma_ctlr_start(priv->dma);
cpsw_intr_enable(priv);

Expand All @@ -1319,10 +1310,12 @@ static int cpsw_ndo_stop(struct net_device *ndev)

cpsw_info(priv, ifdown, "shutting down cpsw device\n");
netif_stop_queue(priv->ndev);
napi_disable(&priv->napi);
netif_carrier_off(priv->ndev);

if (cpsw_common_res_usage_state(priv) <= 1) {
struct cpsw_priv *priv_sl0 = cpsw_get_slave_priv(priv, 0);

napi_disable(&priv_sl0->napi);
cpts_unregister(priv->cpts);
cpsw_intr_disable(priv);
cpdma_ctlr_stop(priv->dma);
Expand Down Expand Up @@ -2105,7 +2098,6 @@ static int cpsw_probe_dual_emac(struct platform_device *pdev,

ndev->netdev_ops = &cpsw_netdev_ops;
ndev->ethtool_ops = &cpsw_ethtool_ops;
netif_napi_add(ndev, &priv_sl2->napi, cpsw_poll, CPSW_POLL_WEIGHT);

/* register the network device */
SET_NETDEV_DEV(ndev, &pdev->dev);
Expand Down

0 comments on commit d354eb8

Please sign in to comment.