priv->hw->mac->set_eee_mode(priv->hw,
priv->plat->en_tx_lpi_clockgating);
}
-@@ -359,14 +434,14 @@ static void stmmac_get_tx_hwtstamp(struc
+@@ -365,14 +440,14 @@ static void stmmac_get_tx_hwtstamp(struc
return;
/* check tx tstamp status */
/* pass tstamp to stack */
skb_tstamp_tx(skb, &shhwtstamp);
}
-@@ -393,19 +468,19 @@ static void stmmac_get_rx_hwtstamp(struc
+@@ -399,19 +474,19 @@ static void stmmac_get_rx_hwtstamp(struc
return;
/* Check if timestamp is available */
}
}
-@@ -471,7 +546,10 @@ static int stmmac_hwtstamp_ioctl(struct
- /* PTP v1, UDP, any kind of event packet */
- config.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
- /* take time stamp for all event messages */
-- snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
-+ if (priv->plat->has_gmac4)
-+ snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
-+ else
-+ snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
-
- ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
- ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA;
-@@ -503,7 +581,10 @@ static int stmmac_hwtstamp_ioctl(struct
- config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
- ptp_v2 = PTP_TCR_TSVER2ENA;
- /* take time stamp for all event messages */
-- snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
-+ if (priv->plat->has_gmac4)
-+ snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
-+ else
-+ snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
-
- ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
- ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA;
-@@ -537,7 +618,10 @@ static int stmmac_hwtstamp_ioctl(struct
- config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
- ptp_v2 = PTP_TCR_TSVER2ENA;
- /* take time stamp for all event messages */
-- snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
-+ if (priv->plat->has_gmac4)
-+ snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
-+ else
-+ snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
-
- ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
- ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA;
-@@ -673,6 +757,19 @@ static void stmmac_release_ptp(struct st
+@@ -688,6 +763,19 @@ static void stmmac_release_ptp(struct st
}
/**
* stmmac_adjust_link - adjusts the link parameters
* @dev: net device structure
* Description: this is the helper called by the physical abstraction layer
-@@ -687,7 +784,6 @@ static void stmmac_adjust_link(struct ne
+@@ -702,7 +790,6 @@ static void stmmac_adjust_link(struct ne
struct phy_device *phydev = dev->phydev;
unsigned long flags;
int new_state = 0;
if (!phydev)
return;
-@@ -709,8 +805,7 @@ static void stmmac_adjust_link(struct ne
+@@ -724,8 +811,7 @@ static void stmmac_adjust_link(struct ne
}
/* Flow Control operation */
if (phydev->pause)
if (phydev->speed != priv->speed) {
new_state = 1;
-@@ -878,22 +973,56 @@ static int stmmac_init_phy(struct net_de
+@@ -893,22 +979,56 @@ static int stmmac_init_phy(struct net_de
return 0;
}
+ priv->hw->desc->display_ring(head_tx, DMA_TX_SIZE, false);
}
+}
++
++static void stmmac_display_rings(struct stmmac_priv *priv)
++{
++ /* Display RX ring */
++ stmmac_display_rx_rings(priv);
- /* Display Rx ring */
- priv->hw->desc->display_ring(head_rx, DMA_RX_SIZE, true);
- /* Display Tx ring */
- priv->hw->desc->display_ring(head_tx, DMA_TX_SIZE, false);
-+static void stmmac_display_rings(struct stmmac_priv *priv)
-+{
-+ /* Display RX ring */
-+ stmmac_display_rx_rings(priv);
-+
+ /* Display TX ring */
+ stmmac_display_tx_rings(priv);
}
static int stmmac_set_bfsize(int mtu, int bufsize)
-@@ -913,48 +1042,88 @@ static int stmmac_set_bfsize(int mtu, in
+@@ -928,48 +1048,88 @@ static int stmmac_set_bfsize(int mtu, in
}
/**
struct sk_buff *skb;
skb = __netdev_alloc_skb_ip_align(priv->dev, priv->dma_buf_sz, flags);
-@@ -963,20 +1132,20 @@ static int stmmac_init_rx_buffers(struct
+@@ -978,20 +1138,20 @@ static int stmmac_init_rx_buffers(struct
"%s: Rx init fails; skb is NULL\n", __func__);
return -ENOMEM;
}
if ((priv->hw->mode->init_desc3) &&
(priv->dma_buf_sz == BUF_SIZE_16KiB))
-@@ -985,30 +1154,71 @@ static int stmmac_init_rx_buffers(struct
+@@ -1000,30 +1160,71 @@ static int stmmac_init_rx_buffers(struct
return 0;
}
if (priv->hw->mode->set_16kib_bfsize)
bfsize = priv->hw->mode->set_16kib_bfsize(dev->mtu);
-@@ -1018,257 +1228,516 @@ static int init_dma_desc_rings(struct ne
+@@ -1033,235 +1234,409 @@ static int init_dma_desc_rings(struct ne
priv->dma_buf_sz = bfsize;
- p = priv->dma_rx + i;
+ for (queue = 0; queue < rx_count; queue++) {
+ struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
-+
+
+- ret = stmmac_init_rx_buffers(priv, p, i, flags);
+- if (ret)
+- goto err_init_rx_buffers;
+ netif_dbg(priv, probe, priv->dev,
+ "(%s) dma_rx_phy=0x%08x\n", __func__,
+ (u32)rx_q->dma_rx_phy);
-+
+
+- netif_dbg(priv, probe, priv->dev, "[%p]\t[%p]\t[%x]\n",
+- priv->rx_skbuff[i], priv->rx_skbuff[i]->data,
+- (unsigned int)priv->rx_skbuff_dma[i]);
+ for (i = 0; i < DMA_RX_SIZE; i++) {
+ struct dma_desc *p;
+
+ p = &((rx_q->dma_erx + i)->basic);
+ else
+ p = rx_q->dma_rx + i;
-
-- ret = stmmac_init_rx_buffers(priv, p, i, flags);
-- if (ret)
-- goto err_init_rx_buffers;
++
+ ret = stmmac_init_rx_buffers(priv, p, i, flags,
+ queue);
+ if (ret)
+ rx_q->dirty_rx = (unsigned int)(i - DMA_RX_SIZE);
+
+ stmmac_clear_rx_descriptors(priv, queue);
-
-- netif_dbg(priv, probe, priv->dev, "[%p]\t[%p]\t[%x]\n",
-- priv->rx_skbuff[i], priv->rx_skbuff[i]->data,
-- (unsigned int)priv->rx_skbuff_dma[i]);
++
+ /* Setup the chained descriptor addresses */
+ if (priv->mode == STMMAC_CHAIN_MODE) {
+ if (priv->extend_desc)
+ priv->hw->mode->init(tx_q->dma_tx,
+ tx_q->dma_tx_phy,
+ DMA_TX_SIZE, 0);
- }
-
-- priv->tx_skbuff_dma[i].buf = 0;
-- priv->tx_skbuff_dma[i].map_as_page = false;
-- priv->tx_skbuff_dma[i].len = 0;
-- priv->tx_skbuff_dma[i].last_segment = false;
-- priv->tx_skbuff[i] = NULL;
++ }
++
+ for (i = 0; i < DMA_TX_SIZE; i++) {
+ struct dma_desc *p;
+ if (priv->extend_desc)
+ tx_q->tx_skbuff_dma[i].len = 0;
+ tx_q->tx_skbuff_dma[i].last_segment = false;
+ tx_q->tx_skbuff[i] = NULL;
-+ }
-+
+ }
+
+- priv->tx_skbuff_dma[i].buf = 0;
+- priv->tx_skbuff_dma[i].map_as_page = false;
+- priv->tx_skbuff_dma[i].len = 0;
+- priv->tx_skbuff_dma[i].last_segment = false;
+- priv->tx_skbuff[i] = NULL;
+ tx_q->dirty_tx = 0;
+ tx_q->cur_tx = 0;
+
- priv->tx_skbuff_dma[i].buf,
- priv->tx_skbuff_dma[i].len,
- DMA_TO_DEVICE);
+- }
+ for (i = 0; i < DMA_TX_SIZE; i++)
+ stmmac_free_tx_buffer(priv, queue, i);
+}
-+
+
+- if (priv->tx_skbuff[i]) {
+- dev_kfree_skb_any(priv->tx_skbuff[i]);
+- priv->tx_skbuff[i] = NULL;
+- priv->tx_skbuff_dma[i].buf = 0;
+- priv->tx_skbuff_dma[i].map_as_page = false;
+- }
+/**
+ * free_dma_rx_desc_resources - free RX dma desc resources
+ * @priv: private structure
+
+ kfree(rx_q->rx_skbuff_dma);
+ kfree(rx_q->rx_skbuff);
-+ }
-+}
-+
-+/**
+ }
+ }
+
+ /**
+- * alloc_dma_desc_resources - alloc TX/RX resources.
+ * free_dma_tx_desc_resources - free TX dma desc resources
+ * @priv: private structure
+ */
+
+/**
+ * alloc_dma_rx_desc_resources - alloc RX resources.
-+ * @priv: private structure
-+ * Description: according to which descriptor can be used (extend or basic)
-+ * this function allocates the resources for TX and RX paths. In case of
-+ * reception, for example, it pre-allocated the RX socket buffer in order to
-+ * allow zero-copy mechanism.
-+ */
+ * @priv: private structure
+ * Description: according to which descriptor can be used (extend or basic)
+ * this function allocates the resources for TX and RX paths. In case of
+ * reception, for example, it pre-allocated the RX socket buffer in order to
+ * allow zero-copy mechanism.
+ */
+-static int alloc_dma_desc_resources(struct stmmac_priv *priv)
+static int alloc_dma_rx_desc_resources(struct stmmac_priv *priv)
-+{
+ {
+ u32 rx_count = priv->plat->rx_queues_to_use;
-+ int ret = -ENOMEM;
+ int ret = -ENOMEM;
+ u32 queue;
-+
+
+- priv->rx_skbuff_dma = kmalloc_array(DMA_RX_SIZE, sizeof(dma_addr_t),
+- GFP_KERNEL);
+- if (!priv->rx_skbuff_dma)
+- return -ENOMEM;
+ /* RX queues buffers and DMA */
+ for (queue = 0; queue < rx_count; queue++) {
+ struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
-+
+
+- priv->rx_skbuff = kmalloc_array(DMA_RX_SIZE, sizeof(struct sk_buff *),
+- GFP_KERNEL);
+- if (!priv->rx_skbuff)
+- goto err_rx_skbuff;
+-
+- priv->tx_skbuff_dma = kmalloc_array(DMA_TX_SIZE,
+- sizeof(*priv->tx_skbuff_dma),
+- GFP_KERNEL);
+- if (!priv->tx_skbuff_dma)
+- goto err_tx_skbuff_dma;
+-
+- priv->tx_skbuff = kmalloc_array(DMA_TX_SIZE, sizeof(struct sk_buff *),
+- GFP_KERNEL);
+- if (!priv->tx_skbuff)
+- goto err_tx_skbuff;
+-
+- if (priv->extend_desc) {
+- priv->dma_erx = dma_zalloc_coherent(priv->device, DMA_RX_SIZE *
+- sizeof(struct
+- dma_extended_desc),
+- &priv->dma_rx_phy,
+- GFP_KERNEL);
+- if (!priv->dma_erx)
+- goto err_dma;
+ rx_q->queue_index = queue;
+ rx_q->priv_data = priv;
-+
+
+- priv->dma_etx = dma_zalloc_coherent(priv->device, DMA_TX_SIZE *
+- sizeof(struct
+- dma_extended_desc),
+- &priv->dma_tx_phy,
+ rx_q->rx_skbuff_dma = kmalloc_array(DMA_RX_SIZE,
+ sizeof(dma_addr_t),
-+ GFP_KERNEL);
+ GFP_KERNEL);
+- if (!priv->dma_etx) {
+- dma_free_coherent(priv->device, DMA_RX_SIZE *
+- sizeof(struct dma_extended_desc),
+- priv->dma_erx, priv->dma_rx_phy);
+- goto err_dma;
+- }
+- } else {
+- priv->dma_rx = dma_zalloc_coherent(priv->device, DMA_RX_SIZE *
+- sizeof(struct dma_desc),
+- &priv->dma_rx_phy,
+- GFP_KERNEL);
+- if (!priv->dma_rx)
+- goto err_dma;
+ if (!rx_q->rx_skbuff_dma)
+ return -ENOMEM;
-+
+
+- priv->dma_tx = dma_zalloc_coherent(priv->device, DMA_TX_SIZE *
+- sizeof(struct dma_desc),
+- &priv->dma_tx_phy,
+- GFP_KERNEL);
+- if (!priv->dma_tx) {
+- dma_free_coherent(priv->device, DMA_RX_SIZE *
+- sizeof(struct dma_desc),
+- priv->dma_rx, priv->dma_rx_phy);
+ rx_q->rx_skbuff = kmalloc_array(DMA_RX_SIZE,
+ sizeof(struct sk_buff *),
+ GFP_KERNEL);
+ if (!rx_q->rx_skbuff)
-+ goto err_dma;
+ goto err_dma;
+
+ if (priv->extend_desc) {
+ rx_q->dma_erx = dma_zalloc_coherent(priv->device,
+ GFP_KERNEL);
+ if (!rx_q->dma_rx)
+ goto err_dma;
-+ }
-+ }
-+
-+ return 0;
-+
-+err_dma:
+ }
+ }
+
+ return 0;
+
+ err_dma:
+- kfree(priv->tx_skbuff);
+-err_tx_skbuff:
+- kfree(priv->tx_skbuff_dma);
+-err_tx_skbuff_dma:
+- kfree(priv->rx_skbuff);
+-err_rx_skbuff:
+- kfree(priv->rx_skbuff_dma);
+ free_dma_rx_desc_resources(priv);
+
+ return ret;
+ GFP_KERNEL);
+ if (!tx_q->dma_tx)
+ goto err_dma_buffers;
- }
++ }
+ }
+
+ return 0;
+
+ ret = alloc_dma_tx_desc_resources(priv);
+
-+ return ret;
-+}
-+
+ return ret;
+ }
+
+/**
+ * free_dma_desc_resources - free dma desc resources
+ * @priv: private structure
+ */
-+static void free_dma_desc_resources(struct stmmac_priv *priv)
-+{
+ static void free_dma_desc_resources(struct stmmac_priv *priv)
+ {
+- /* Release the DMA TX/RX socket buffers */
+- dma_free_rx_skbufs(priv);
+- dma_free_tx_skbufs(priv);
+-
+- /* Free DMA regions of consistent memory previously allocated */
+- if (!priv->extend_desc) {
+- dma_free_coherent(priv->device,
+- DMA_TX_SIZE * sizeof(struct dma_desc),
+- priv->dma_tx, priv->dma_tx_phy);
+- dma_free_coherent(priv->device,
+- DMA_RX_SIZE * sizeof(struct dma_desc),
+- priv->dma_rx, priv->dma_rx_phy);
+- } else {
+- dma_free_coherent(priv->device, DMA_TX_SIZE *
+- sizeof(struct dma_extended_desc),
+- priv->dma_etx, priv->dma_tx_phy);
+- dma_free_coherent(priv->device, DMA_RX_SIZE *
+- sizeof(struct dma_extended_desc),
+- priv->dma_erx, priv->dma_rx_phy);
+- }
+- kfree(priv->rx_skbuff_dma);
+- kfree(priv->rx_skbuff);
+- kfree(priv->tx_skbuff_dma);
+- kfree(priv->tx_skbuff);
+ /* Release the DMA RX socket buffers */
+ free_dma_rx_desc_resources(priv);
+
+ /* Release the DMA TX socket buffers */
+ free_dma_tx_desc_resources(priv);
-+}
-+
-+/**
-+ * stmmac_mac_enable_rx_queues - Enable MAC rx queues
-+ * @priv: driver private structure
-+ * Description: It is used for enabling the rx queues in the MAC
-+ */
-+static void stmmac_mac_enable_rx_queues(struct stmmac_priv *priv)
-+{
+ }
+
+ /**
+@@ -1271,19 +1646,104 @@ static void free_dma_desc_resources(stru
+ */
+ static void stmmac_mac_enable_rx_queues(struct stmmac_priv *priv)
+ {
+- int rx_count = priv->dma_cap.number_rx_queues;
+- int queue = 0;
+ u32 rx_queues_count = priv->plat->rx_queues_to_use;
+ int queue;
+ u8 mode;
-- if (priv->tx_skbuff[i]) {
-- dev_kfree_skb_any(priv->tx_skbuff[i]);
-- priv->tx_skbuff[i] = NULL;
-- priv->tx_skbuff_dma[i].buf = 0;
-- priv->tx_skbuff_dma[i].map_as_page = false;
-- }
+- /* If GMAC does not have multiple queues, then this is not necessary*/
+- if (rx_count == 1)
+- return;
+ for (queue = 0; queue < rx_queues_count; queue++) {
+ mode = priv->plat->rx_queues_cfg[queue].mode_to_use;
+ priv->hw->mac->rx_queue_enable(priv->hw, mode, queue);
- }
- }
++ }
++}
- /**
-- * alloc_dma_desc_resources - alloc TX/RX resources.
-- * @priv: private structure
-- * Description: according to which descriptor can be used (extend or basic)
-- * this function allocates the resources for TX and RX paths. In case of
-- * reception, for example, it pre-allocated the RX socket buffer in order to
-- * allow zero-copy mechanism.
+- /**
+- * If the core is synthesized with multiple rx queues / multiple
+- * dma channels, then rx queues will be disabled by default.
+- * For now only rx queue 0 is enabled.
+- */
+- priv->hw->mac->rx_queue_enable(priv->hw, queue);
++/**
+ * stmmac_start_rx_dma - start RX DMA channel
+ * @priv: driver private structure
+ * @chan: RX channel index
+ * Description:
+ * This starts a RX DMA channel
- */
--static int alloc_dma_desc_resources(struct stmmac_priv *priv)
++ */
+static void stmmac_start_rx_dma(struct stmmac_priv *priv, u32 chan)
- {
-- int ret = -ENOMEM;
--
-- priv->rx_skbuff_dma = kmalloc_array(DMA_RX_SIZE, sizeof(dma_addr_t),
-- GFP_KERNEL);
-- if (!priv->rx_skbuff_dma)
-- return -ENOMEM;
--
-- priv->rx_skbuff = kmalloc_array(DMA_RX_SIZE, sizeof(struct sk_buff *),
-- GFP_KERNEL);
-- if (!priv->rx_skbuff)
-- goto err_rx_skbuff;
--
-- priv->tx_skbuff_dma = kmalloc_array(DMA_TX_SIZE,
-- sizeof(*priv->tx_skbuff_dma),
-- GFP_KERNEL);
-- if (!priv->tx_skbuff_dma)
-- goto err_tx_skbuff_dma;
--
-- priv->tx_skbuff = kmalloc_array(DMA_TX_SIZE, sizeof(struct sk_buff *),
-- GFP_KERNEL);
-- if (!priv->tx_skbuff)
-- goto err_tx_skbuff;
--
-- if (priv->extend_desc) {
-- priv->dma_erx = dma_zalloc_coherent(priv->device, DMA_RX_SIZE *
-- sizeof(struct
-- dma_extended_desc),
-- &priv->dma_rx_phy,
-- GFP_KERNEL);
-- if (!priv->dma_erx)
-- goto err_dma;
--
-- priv->dma_etx = dma_zalloc_coherent(priv->device, DMA_TX_SIZE *
-- sizeof(struct
-- dma_extended_desc),
-- &priv->dma_tx_phy,
-- GFP_KERNEL);
-- if (!priv->dma_etx) {
-- dma_free_coherent(priv->device, DMA_RX_SIZE *
-- sizeof(struct dma_extended_desc),
-- priv->dma_erx, priv->dma_rx_phy);
-- goto err_dma;
-- }
-- } else {
-- priv->dma_rx = dma_zalloc_coherent(priv->device, DMA_RX_SIZE *
-- sizeof(struct dma_desc),
-- &priv->dma_rx_phy,
-- GFP_KERNEL);
-- if (!priv->dma_rx)
-- goto err_dma;
++{
+ netdev_dbg(priv->dev, "DMA RX processes started in channel %d\n", chan);
+ priv->hw->dma->start_rx(priv->ioaddr, chan);
+}
-
-- priv->dma_tx = dma_zalloc_coherent(priv->device, DMA_TX_SIZE *
-- sizeof(struct dma_desc),
-- &priv->dma_tx_phy,
-- GFP_KERNEL);
-- if (!priv->dma_tx) {
-- dma_free_coherent(priv->device, DMA_RX_SIZE *
-- sizeof(struct dma_desc),
-- priv->dma_rx, priv->dma_rx_phy);
-- goto err_dma;
-- }
-- }
++
+/**
+ * stmmac_start_tx_dma - start TX DMA channel
+ * @priv: driver private structure
+ netdev_dbg(priv->dev, "DMA TX processes started in channel %d\n", chan);
+ priv->hw->dma->start_tx(priv->ioaddr, chan);
+}
-
-- return 0;
++
+/**
+ * stmmac_stop_rx_dma - stop RX DMA channel
+ * @priv: driver private structure
+ netdev_dbg(priv->dev, "DMA RX processes stopped in channel %d\n", chan);
+ priv->hw->dma->stop_rx(priv->ioaddr, chan);
+}
-
--err_dma:
-- kfree(priv->tx_skbuff);
--err_tx_skbuff:
-- kfree(priv->tx_skbuff_dma);
--err_tx_skbuff_dma:
-- kfree(priv->rx_skbuff);
--err_rx_skbuff:
-- kfree(priv->rx_skbuff_dma);
-- return ret;
++
+/**
+ * stmmac_stop_tx_dma - stop TX DMA channel
+ * @priv: driver private structure
+{
+ netdev_dbg(priv->dev, "DMA TX processes stopped in channel %d\n", chan);
+ priv->hw->dma->stop_tx(priv->ioaddr, chan);
- }
-
--static void free_dma_desc_resources(struct stmmac_priv *priv)
++}
++
+/**
+ * stmmac_start_all_dma - start all RX and TX DMA channels
+ * @priv: driver private structure
+ * This starts all the RX and TX DMA channels
+ */
+static void stmmac_start_all_dma(struct stmmac_priv *priv)
- {
-- /* Release the DMA TX/RX socket buffers */
-- dma_free_rx_skbufs(priv);
-- dma_free_tx_skbufs(priv);
--
-- /* Free DMA regions of consistent memory previously allocated */
-- if (!priv->extend_desc) {
-- dma_free_coherent(priv->device,
-- DMA_TX_SIZE * sizeof(struct dma_desc),
-- priv->dma_tx, priv->dma_tx_phy);
-- dma_free_coherent(priv->device,
-- DMA_RX_SIZE * sizeof(struct dma_desc),
-- priv->dma_rx, priv->dma_rx_phy);
-- } else {
-- dma_free_coherent(priv->device, DMA_TX_SIZE *
-- sizeof(struct dma_extended_desc),
-- priv->dma_etx, priv->dma_tx_phy);
-- dma_free_coherent(priv->device, DMA_RX_SIZE *
-- sizeof(struct dma_extended_desc),
-- priv->dma_erx, priv->dma_rx_phy);
-- }
-- kfree(priv->rx_skbuff_dma);
-- kfree(priv->rx_skbuff);
-- kfree(priv->tx_skbuff_dma);
-- kfree(priv->tx_skbuff);
++{
+ u32 rx_channels_count = priv->plat->rx_queues_to_use;
+ u32 tx_channels_count = priv->plat->tx_queues_to_use;
+ u32 chan = 0;
+
+ for (chan = 0; chan < tx_channels_count; chan++)
+ stmmac_start_tx_dma(priv, chan);
- }
-
- /**
-- * stmmac_mac_enable_rx_queues - Enable MAC rx queues
-- * @priv: driver private structure
-- * Description: It is used for enabling the rx queues in the MAC
++}
++
++/**
+ * stmmac_stop_all_dma - stop all RX and TX DMA channels
+ * @priv: driver private structure
+ * Description:
+ * This stops the RX and TX DMA channels
- */
--static void stmmac_mac_enable_rx_queues(struct stmmac_priv *priv)
++ */
+static void stmmac_stop_all_dma(struct stmmac_priv *priv)
- {
-- int rx_count = priv->dma_cap.number_rx_queues;
-- int queue = 0;
++{
+ u32 rx_channels_count = priv->plat->rx_queues_to_use;
+ u32 tx_channels_count = priv->plat->tx_queues_to_use;
+ u32 chan = 0;
-
-- /* If GMAC does not have multiple queues, then this is not necessary*/
-- if (rx_count == 1)
-- return;
++
+ for (chan = 0; chan < rx_channels_count; chan++)
+ stmmac_stop_rx_dma(priv, chan);
-
-- /**
-- * If the core is synthesized with multiple rx queues / multiple
-- * dma channels, then rx queues will be disabled by default.
-- * For now only rx queue 0 is enabled.
-- */
-- priv->hw->mac->rx_queue_enable(priv->hw, queue);
++
+ for (chan = 0; chan < tx_channels_count; chan++)
+ stmmac_stop_tx_dma(priv, chan);
}
/**
-@@ -1279,11 +1748,20 @@ static void stmmac_mac_enable_rx_queues(
+@@ -1294,11 +1754,20 @@ static void stmmac_mac_enable_rx_queues(
*/
static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
{
/*
* In case of GMAC, SF mode can be enabled
* to perform the TX COE in HW. This depends on:
-@@ -1291,37 +1769,53 @@ static void stmmac_dma_operation_mode(st
+@@ -1306,37 +1775,53 @@ static void stmmac_dma_operation_mode(st
* 2) There is no bugged Jumbo frame support
* that needs to not insert csum in the TDES.
*/
status = priv->hw->desc->tx_status(&priv->dev->stats,
&priv->xstats, p,
-@@ -1342,48 +1836,51 @@ static void stmmac_tx_clean(struct stmma
+@@ -1362,48 +1847,51 @@ static void stmmac_tx_clean(struct stmma
stmmac_get_tx_hwtstamp(priv, p, skb);
}
}
if ((priv->eee_enabled) && (!priv->tx_path_in_lpi_mode)) {
-@@ -1393,45 +1890,76 @@ static void stmmac_tx_clean(struct stmma
+@@ -1413,45 +1901,76 @@ static void stmmac_tx_clean(struct stmma
netif_tx_unlock(priv->dev);
}
}
/**
-@@ -1443,31 +1971,43 @@ static void stmmac_tx_err(struct stmmac_
+@@ -1463,31 +1982,43 @@ static void stmmac_tx_err(struct stmmac_
*/
static void stmmac_dma_interrupt(struct stmmac_priv *priv)
{
}
/**
-@@ -1574,6 +2114,13 @@ static void stmmac_check_ether_addr(stru
+@@ -1594,6 +2125,13 @@ static void stmmac_check_ether_addr(stru
*/
static int stmmac_init_dma_engine(struct stmmac_priv *priv)
{
int atds = 0;
int ret = 0;
-@@ -1591,19 +2138,49 @@ static int stmmac_init_dma_engine(struct
+@@ -1611,19 +2149,49 @@ static int stmmac_init_dma_engine(struct
return ret;
}
}
if (priv->plat->axi && priv->hw->dma->axi)
-@@ -1621,8 +2198,12 @@ static int stmmac_init_dma_engine(struct
+@@ -1641,8 +2209,12 @@ static int stmmac_init_dma_engine(struct
static void stmmac_tx_timer(unsigned long data)
{
struct stmmac_priv *priv = (struct stmmac_priv *)data;
}
/**
-@@ -1644,6 +2225,196 @@ static void stmmac_init_tx_coalesce(stru
+@@ -1664,6 +2236,196 @@ static void stmmac_init_tx_coalesce(stru
add_timer(&priv->txtimer);
}
/**
* stmmac_hw_setup - setup mac in a usable state.
* @dev : pointer to the device structure.
-@@ -1659,6 +2430,9 @@ static void stmmac_init_tx_coalesce(stru
+@@ -1679,6 +2441,9 @@ static void stmmac_init_tx_coalesce(stru
static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
{
struct stmmac_priv *priv = netdev_priv(dev);
int ret;
/* DMA initialization and SW reset */
-@@ -1688,9 +2462,9 @@ static int stmmac_hw_setup(struct net_de
+@@ -1708,9 +2473,9 @@ static int stmmac_hw_setup(struct net_de
/* Initialize the MAC Core */
priv->hw->mac->core_init(priv->hw, dev->mtu);
ret = priv->hw->mac->rx_ipc(priv->hw);
if (!ret) {
-@@ -1700,10 +2474,7 @@ static int stmmac_hw_setup(struct net_de
+@@ -1720,10 +2485,7 @@ static int stmmac_hw_setup(struct net_de
}
/* Enable the MAC Rx/Tx */
/* Set the HW DMA mode and the COE */
stmmac_dma_operation_mode(priv);
-@@ -1711,6 +2482,10 @@ static int stmmac_hw_setup(struct net_de
+@@ -1731,6 +2493,10 @@ static int stmmac_hw_setup(struct net_de
stmmac_mmc_setup(priv);
if (init_ptp) {
ret = stmmac_init_ptp(priv);
if (ret == -EOPNOTSUPP)
netdev_warn(priv->dev, "PTP not supported by HW\n");
-@@ -1725,35 +2500,37 @@ static int stmmac_hw_setup(struct net_de
+@@ -1745,35 +2511,37 @@ static int stmmac_hw_setup(struct net_de
__func__);
#endif
/* Start the ball rolling... */
/**
* stmmac_open - open entry point of the driver
* @dev : pointer to the device structure.
-@@ -1821,7 +2598,7 @@ static int stmmac_open(struct net_device
+@@ -1842,7 +2610,7 @@ static int stmmac_open(struct net_device
netdev_err(priv->dev,
"%s: ERROR: allocating the IRQ %d (error: %d)\n",
__func__, dev->irq, ret);
}
/* Request the Wake IRQ in case of another line is used for WoL */
-@@ -1848,8 +2625,8 @@ static int stmmac_open(struct net_device
+@@ -1869,8 +2637,8 @@ static int stmmac_open(struct net_device
}
}
return 0;
-@@ -1858,7 +2635,12 @@ lpiirq_error:
+@@ -1879,7 +2647,12 @@ lpiirq_error:
free_irq(priv->wol_irq, dev);
wolirq_error:
free_irq(dev->irq, dev);
init_error:
free_dma_desc_resources(priv);
dma_desc_error:
-@@ -1887,9 +2669,9 @@ static int stmmac_release(struct net_dev
+@@ -1908,9 +2681,9 @@ static int stmmac_release(struct net_dev
phy_disconnect(dev->phydev);
}
del_timer_sync(&priv->txtimer);
-@@ -1901,14 +2683,13 @@ static int stmmac_release(struct net_dev
+@@ -1922,14 +2695,13 @@ static int stmmac_release(struct net_dev
free_irq(priv->lpi_irq, dev);
/* Stop TX/RX DMA and clear the descriptors */
netif_carrier_off(dev);
-@@ -1927,22 +2708,24 @@ static int stmmac_release(struct net_dev
+@@ -1948,22 +2720,24 @@ static int stmmac_release(struct net_dev
* @des: buffer start address
* @total_len: total length to fill in descriptors
* @last_segmant: condition for the last descriptor
desc->des0 = cpu_to_le32(des + (total_len - tmp_len));
buff_size = tmp_len >= TSO_MAX_BUFF_SIZE ?
-@@ -1950,7 +2733,7 @@ static void stmmac_tso_allocator(struct
+@@ -1971,7 +2745,7 @@ static void stmmac_tso_allocator(struct
priv->hw->desc->prepare_tso_tx_desc(desc, 0, buff_size,
0, 1,
0, 0);
tmp_len -= TSO_MAX_BUFF_SIZE;
-@@ -1986,23 +2769,28 @@ static void stmmac_tso_allocator(struct
+@@ -2007,23 +2781,28 @@ static void stmmac_tso_allocator(struct
*/
static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
{
/* This is a hard error, log it. */
netdev_err(priv->dev,
"%s: Tx Ring full when queue awake\n",
-@@ -2017,10 +2805,10 @@ static netdev_tx_t stmmac_tso_xmit(struc
+@@ -2038,10 +2817,10 @@ static netdev_tx_t stmmac_tso_xmit(struc
/* set new MSS value if needed */
if (mss != priv->mss) {
}
if (netif_msg_tx_queued(priv)) {
-@@ -2030,9 +2818,9 @@ static netdev_tx_t stmmac_tso_xmit(struc
+@@ -2051,9 +2830,9 @@ static netdev_tx_t stmmac_tso_xmit(struc
skb->data_len);
}
first = desc;
/* first descriptor: fill Headers on Buf1 */
-@@ -2041,9 +2829,8 @@ static netdev_tx_t stmmac_tso_xmit(struc
+@@ -2062,9 +2841,8 @@ static netdev_tx_t stmmac_tso_xmit(struc
if (dma_mapping_error(priv->device, des))
goto dma_map_err;
first->des0 = cpu_to_le32(des);
-@@ -2054,7 +2841,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
+@@ -2075,7 +2853,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
/* If needed take extra descriptors to fill the remaining payload */
tmp_pay_len = pay_len - TSO_MAX_BUFF_SIZE;
/* Prepare fragments */
for (i = 0; i < nfrags; i++) {
-@@ -2063,24 +2850,34 @@ static netdev_tx_t stmmac_tso_xmit(struc
+@@ -2084,24 +2862,34 @@ static netdev_tx_t stmmac_tso_xmit(struc
des = skb_frag_dma_map(priv->device, frag, 0,
skb_frag_size(frag),
DMA_TO_DEVICE);
}
dev->stats.tx_bytes += skb->len;
-@@ -2112,7 +2909,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
+@@ -2133,7 +2921,7 @@ static netdev_tx_t stmmac_tso_xmit(struc
priv->hw->desc->prepare_tso_tx_desc(first, 1,
proto_hdr_len,
pay_len,
tcp_hdrlen(skb) / 4, (skb->len - proto_hdr_len));
/* If context desc is used to change MSS */
-@@ -2127,20 +2924,20 @@ static netdev_tx_t stmmac_tso_xmit(struc
+@@ -2155,20 +2943,20 @@ static netdev_tx_t stmmac_tso_xmit(struc
if (netif_msg_pktdata(priv)) {
pr_info("%s: curr=%d dirty=%d f=%d, e=%d, f_p=%p, nfrags %d\n",
return NETDEV_TX_OK;
-@@ -2164,21 +2961,27 @@ static netdev_tx_t stmmac_xmit(struct sk
+@@ -2192,21 +2980,27 @@ static netdev_tx_t stmmac_xmit(struct sk
struct stmmac_priv *priv = netdev_priv(dev);
unsigned int nopaged_len = skb_headlen(skb);
int i, csum_insertion = 0, is_jumbo = 0;
/* This is a hard error, log it. */
netdev_err(priv->dev,
"%s: Tx Ring full when queue awake\n",
-@@ -2190,20 +2993,18 @@ static netdev_tx_t stmmac_xmit(struct sk
+@@ -2218,20 +3012,18 @@ static netdev_tx_t stmmac_xmit(struct sk
if (priv->tx_path_in_lpi_mode)
stmmac_disable_eee_mode(priv);
enh_desc = priv->plat->enh_desc;
/* To program the descriptors according to the size of the frame */
if (enh_desc)
-@@ -2211,7 +3012,7 @@ static netdev_tx_t stmmac_xmit(struct sk
+@@ -2239,7 +3031,7 @@ static netdev_tx_t stmmac_xmit(struct sk
if (unlikely(is_jumbo) && likely(priv->synopsys_id <
DWMAC_CORE_4_00)) {
if (unlikely(entry < 0))
goto dma_map_err;
}
-@@ -2224,48 +3025,56 @@ static netdev_tx_t stmmac_xmit(struct sk
+@@ -2252,48 +3044,56 @@ static netdev_tx_t stmmac_xmit(struct sk
entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE);
if (likely(priv->extend_desc))
priv->hw->desc->display_ring(tx_head, DMA_TX_SIZE, false);
-@@ -2273,10 +3082,10 @@ static netdev_tx_t stmmac_xmit(struct sk
+@@ -2301,10 +3101,10 @@ static netdev_tx_t stmmac_xmit(struct sk
print_pkt(skb->data, skb->len);
}
}
dev->stats.tx_bytes += skb->len;
-@@ -2311,14 +3120,14 @@ static netdev_tx_t stmmac_xmit(struct sk
+@@ -2339,14 +3139,14 @@ static netdev_tx_t stmmac_xmit(struct sk
if (dma_mapping_error(priv->device, des))
goto dma_map_err;
if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
priv->hwts_tx_en)) {
-@@ -2330,7 +3139,7 @@ static netdev_tx_t stmmac_xmit(struct sk
+@@ -2358,7 +3158,7 @@ static netdev_tx_t stmmac_xmit(struct sk
/* Prepare the first descriptor setting the OWN bit too */
priv->hw->desc->prepare_tx_desc(first, 1, nopaged_len,
csum_insertion, priv->mode, 1,
/* The own bit must be the latest setting done when prepare the
* descriptor and then barrier is needed to make sure that
-@@ -2339,13 +3148,13 @@ static netdev_tx_t stmmac_xmit(struct sk
+@@ -2367,13 +3167,13 @@ static netdev_tx_t stmmac_xmit(struct sk
dma_wmb();
}
return NETDEV_TX_OK;
-@@ -2373,9 +3182,9 @@ static void stmmac_rx_vlan(struct net_de
+@@ -2401,9 +3201,9 @@ static void stmmac_rx_vlan(struct net_de
}
return 0;
return 1;
-@@ -2384,30 +3193,33 @@ static inline int stmmac_rx_threshold_co
+@@ -2412,30 +3212,33 @@ static inline int stmmac_rx_threshold_co
/**
* stmmac_rx_refill - refill used skb preallocated buffers
* @priv: driver private structure
if (unlikely(net_ratelimit()))
dev_err(priv->device,
"fail to alloc skb entry %d\n",
-@@ -2415,28 +3227,28 @@ static inline void stmmac_rx_refill(stru
+@@ -2443,28 +3246,28 @@ static inline void stmmac_rx_refill(stru
break;
}
netif_dbg(priv, rx_status, priv->dev,
"refill entry #%d\n", entry);
-@@ -2452,31 +3264,33 @@ static inline void stmmac_rx_refill(stru
+@@ -2480,31 +3283,33 @@ static inline void stmmac_rx_refill(stru
entry = STMMAC_GET_ENTRY(entry, DMA_RX_SIZE);
}
priv->hw->desc->display_ring(rx_head, DMA_RX_SIZE, true);
}
-@@ -2486,9 +3300,9 @@ static int stmmac_rx(struct stmmac_priv
+@@ -2514,9 +3319,9 @@ static int stmmac_rx(struct stmmac_priv
struct dma_desc *np;
if (priv->extend_desc)
/* read the status of the incoming frame */
status = priv->hw->desc->rx_status(&priv->dev->stats,
-@@ -2499,20 +3313,20 @@ static int stmmac_rx(struct stmmac_priv
+@@ -2527,20 +3332,20 @@ static int stmmac_rx(struct stmmac_priv
count++;
entry);
if (unlikely(status == discard_frame)) {
priv->dev->stats.rx_errors++;
-@@ -2522,9 +3336,9 @@ static int stmmac_rx(struct stmmac_priv
+@@ -2550,9 +3355,9 @@ static int stmmac_rx(struct stmmac_priv
* them in stmmac_rx_refill() function so that
* device can reuse it.
*/
priv->dma_buf_sz,
DMA_FROM_DEVICE);
}
-@@ -2572,7 +3386,7 @@ static int stmmac_rx(struct stmmac_priv
+@@ -2600,7 +3405,7 @@ static int stmmac_rx(struct stmmac_priv
*/
if (unlikely(!priv->plat->has_gmac4 &&
((frame_len < priv->rx_copybreak) ||
skb = netdev_alloc_skb_ip_align(priv->dev,
frame_len);
if (unlikely(!skb)) {
-@@ -2584,21 +3398,21 @@ static int stmmac_rx(struct stmmac_priv
+@@ -2612,21 +3417,21 @@ static int stmmac_rx(struct stmmac_priv
}
dma_sync_single_for_cpu(priv->device,
if (unlikely(!skb)) {
netdev_err(priv->dev,
"%s: Inconsistent Rx chain\n",
-@@ -2607,12 +3421,12 @@ static int stmmac_rx(struct stmmac_priv
+@@ -2635,12 +3440,12 @@ static int stmmac_rx(struct stmmac_priv
break;
}
prefetch(skb->data - NET_IP_ALIGN);
priv->dma_buf_sz,
DMA_FROM_DEVICE);
}
-@@ -2634,7 +3448,7 @@ static int stmmac_rx(struct stmmac_priv
+@@ -2662,7 +3467,7 @@ static int stmmac_rx(struct stmmac_priv
else
skb->ip_summed = CHECKSUM_UNNECESSARY;
priv->dev->stats.rx_packets++;
priv->dev->stats.rx_bytes += frame_len;
-@@ -2642,7 +3456,7 @@ static int stmmac_rx(struct stmmac_priv
+@@ -2670,7 +3475,7 @@ static int stmmac_rx(struct stmmac_priv
entry = next_entry;
}
priv->xstats.rx_pkt_n += count;
-@@ -2659,16 +3473,24 @@ static int stmmac_rx(struct stmmac_priv
+@@ -2687,16 +3492,24 @@ static int stmmac_rx(struct stmmac_priv
*/
static int stmmac_poll(struct napi_struct *napi, int budget)
{
}
return work_done;
}
-@@ -2684,9 +3506,12 @@ static int stmmac_poll(struct napi_struc
+@@ -2712,9 +3525,12 @@ static int stmmac_poll(struct napi_struc
static void stmmac_tx_timeout(struct net_device *dev)
{
struct stmmac_priv *priv = netdev_priv(dev);
}
/**
-@@ -2809,6 +3634,12 @@ static irqreturn_t stmmac_interrupt(int
+@@ -2837,6 +3653,12 @@ static irqreturn_t stmmac_interrupt(int
{
struct net_device *dev = (struct net_device *)dev_id;
struct stmmac_priv *priv = netdev_priv(dev);
if (priv->irq_wake)
pm_wakeup_event(priv->device, 0);
-@@ -2822,16 +3653,30 @@ static irqreturn_t stmmac_interrupt(int
+@@ -2850,16 +3672,30 @@ static irqreturn_t stmmac_interrupt(int
if ((priv->plat->has_gmac) || (priv->plat->has_gmac4)) {
int status = priv->hw->mac->host_irq_status(priv->hw,
&priv->xstats);
}
/* PCS link status */
-@@ -2916,7 +3761,7 @@ static void sysfs_display_ring(void *hea
+@@ -2944,7 +3780,7 @@ static void sysfs_display_ring(void *hea
ep++;
} else {
seq_printf(seq, "%d [0x%x]: 0x%x 0x%x 0x%x 0x%x\n",
le32_to_cpu(p->des0), le32_to_cpu(p->des1),
le32_to_cpu(p->des2), le32_to_cpu(p->des3));
p++;
-@@ -2929,17 +3774,40 @@ static int stmmac_sysfs_ring_read(struct
+@@ -2957,17 +3793,40 @@ static int stmmac_sysfs_ring_read(struct
{
struct net_device *dev = seq->private;
struct stmmac_priv *priv = netdev_priv(dev);
}
return 0;
-@@ -3222,11 +4090,14 @@ int stmmac_dvr_probe(struct device *devi
+@@ -3250,11 +4109,14 @@ int stmmac_dvr_probe(struct device *devi
struct plat_stmmacenet_data *plat_dat,
struct stmmac_resources *res)
{
if (!ndev)
return -ENOMEM;
-@@ -3268,6 +4139,10 @@ int stmmac_dvr_probe(struct device *devi
+@@ -3296,6 +4158,10 @@ int stmmac_dvr_probe(struct device *devi
if (ret)
goto error_hw_init;
ndev->netdev_ops = &stmmac_netdev_ops;
ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-@@ -3300,7 +4175,12 @@ int stmmac_dvr_probe(struct device *devi
+@@ -3328,7 +4194,12 @@ int stmmac_dvr_probe(struct device *devi
"Enable RX Mitigation via HW Watchdog Timer\n");
}
spin_lock_init(&priv->lock);
-@@ -3345,7 +4225,11 @@ error_netdev_register:
+@@ -3373,7 +4244,11 @@ error_netdev_register:
priv->hw->pcs != STMMAC_PCS_RTBI)
stmmac_mdio_unregister(ndev);
error_mdio_register:
error_hw_init:
free_netdev(ndev);
-@@ -3366,10 +4250,9 @@ int stmmac_dvr_remove(struct device *dev
+@@ -3394,10 +4269,9 @@ int stmmac_dvr_remove(struct device *dev
netdev_info(priv->dev, "%s: removing driver", __func__);
netif_carrier_off(ndev);
unregister_netdev(ndev);
if (priv->plat->stmmac_rst)
-@@ -3408,20 +4291,19 @@ int stmmac_suspend(struct device *dev)
+@@ -3436,20 +4310,19 @@ int stmmac_suspend(struct device *dev)
spin_lock_irqsave(&priv->lock, flags);
netif_device_detach(ndev);
pinctrl_pm_select_sleep_state(priv->device);
/* Disable clock in case of PWM is off */
clk_disable(priv->plat->pclk);
-@@ -3437,6 +4319,31 @@ int stmmac_suspend(struct device *dev)
+@@ -3465,6 +4338,31 @@ int stmmac_suspend(struct device *dev)
EXPORT_SYMBOL_GPL(stmmac_suspend);
/**
* stmmac_resume - resume callback
* @dev: device pointer
* Description: when resume this function is invoked to setup the DMA and CORE
-@@ -3476,10 +4383,8 @@ int stmmac_resume(struct device *dev)
+@@ -3504,10 +4402,8 @@ int stmmac_resume(struct device *dev)
spin_lock_irqsave(&priv->lock, flags);
/* reset private mss value to force mss context settings at
* next tso xmit (only used for gmac4).
*/
-@@ -3491,9 +4396,9 @@ int stmmac_resume(struct device *dev)
+@@ -3519,9 +4415,9 @@ int stmmac_resume(struct device *dev)
stmmac_init_tx_coalesce(priv);
stmmac_set_rx_mode(ndev);
plat->clk_ptp_rate = clk_get_rate(plat->clk_ptp_ref);
dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate);
}
---- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
-+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
-@@ -59,7 +59,8 @@
- /* Enable Snapshot for Messages Relevant to Master */
- #define PTP_TCR_TSMSTRENA BIT(15)
- /* Select PTP packets for Taking Snapshots */
--#define PTP_TCR_SNAPTYPSEL_1 GENMASK(17, 16)
-+#define PTP_TCR_SNAPTYPSEL_1 BIT(16)
-+#define PTP_GMAC4_TCR_SNAPTYPSEL_1 GENMASK(17, 16)
- /* Enable MAC address for PTP Frame Filtering */
- #define PTP_TCR_TSENMACADDR BIT(18)
-
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -28,6 +28,9 @@