|
| 1 | +diff --git a/mvpp2/mvpp2_main.c b/mvpp2/mvpp2_main.c |
| 2 | +index 3880dcc0418b..3ea0c4928921 100644 |
| 3 | +--- a/mvpp2/mvpp2_main.c |
| 4 | ++++ b/mvpp2/mvpp2_main.c |
| 5 | +@@ -43,6 +43,10 @@ |
| 6 | + #include "mvpp2_prs.h" |
| 7 | + #include "mvpp2_cls.h" |
| 8 | + |
| 9 | ++#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) |
| 10 | ++#include <mvpp2_netmap.h> |
| 11 | ++#endif |
| 12 | ++ |
| 13 | + enum mvpp2_bm_pool_log_num { |
| 14 | + MVPP2_BM_SHORT, |
| 15 | + MVPP2_BM_LONG, |
| 16 | +@@ -687,7 +691,7 @@ static int mvpp2_bm_init(struct device *dev, struct mvpp2 *priv) |
| 17 | + } |
| 18 | + |
| 19 | + /* Allocate and initialize BM pools */ |
| 20 | +- priv->bm_pools = devm_kcalloc(dev, poolnum, |
| 21 | ++ priv->bm_pools = devm_kcalloc(dev, MVPP2_BM_MAX_POOLS, |
| 22 | + sizeof(*priv->bm_pools), GFP_KERNEL); |
| 23 | + if (!priv->bm_pools) |
| 24 | + return -ENOMEM; |
| 25 | +@@ -1460,7 +1464,11 @@ static void mvpp2_interrupts_unmask(void *arg) |
| 26 | + |
| 27 | + val = MVPP2_CAUSE_MISC_SUM_MASK | |
| 28 | + MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK(port->priv->hw_version); |
| 29 | ++#ifdef CONFIG_NETMAP |
| 30 | ++ if (port->has_tx_irqs && !nm_netmap_on(NA(port->dev))) |
| 31 | ++#else |
| 32 | + if (port->has_tx_irqs) |
| 33 | ++#endif |
| 34 | + val |= MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK; |
| 35 | + |
| 36 | + mvpp2_thread_write(port->priv, thread, |
| 37 | +@@ -2987,7 +2995,11 @@ static int mvpp2_rxq_init(struct mvpp2_port *port, |
| 38 | + put_cpu(); |
| 39 | + |
| 40 | + /* Set Offset */ |
| 41 | ++#ifdef CONFIG_NETMAP |
| 42 | ++ mvpp2_netmap_rxq_offset_set(port, rxq->id); |
| 43 | ++#else |
| 44 | + mvpp2_rxq_offset_set(port, rxq->id, MVPP2_SKB_HEADROOM); |
| 45 | ++#endif |
| 46 | + |
| 47 | + /* Set coalescing pkts and time */ |
| 48 | + mvpp2_rx_pkts_coal_set(port, rxq); |
| 49 | +@@ -3377,6 +3389,11 @@ static irqreturn_t mvpp2_isr(int irq, void *dev_id) |
| 50 | + { |
| 51 | + struct mvpp2_queue_vector *qv = dev_id; |
| 52 | + |
| 53 | ++#ifdef CONFIG_NETMAP |
| 54 | ++ if (mvpp2_netmap_rx_irq(qv)) |
| 55 | ++ return IRQ_HANDLED; |
| 56 | ++#endif /* DEV_NETMAP */ |
| 57 | ++ |
| 58 | + mvpp2_qvec_interrupt_disable(qv); |
| 59 | + |
| 60 | + napi_schedule(&qv->napi); |
| 61 | +@@ -4394,6 +4411,12 @@ static netdev_tx_t mvpp2_tx(struct sk_buff *skb, struct net_device *dev) |
| 62 | + } |
| 63 | + frags = skb_shinfo(skb)->nr_frags + 1; |
| 64 | + |
| 65 | ++#ifdef CONFIG_NETMAP |
| 66 | ++ /* Process all TX queues on this port for this thread/core */ |
| 67 | ++ if (port->has_tx_irqs && nm_netmap_on(NA(dev))) { |
| 68 | ++ mvpp2_tx_done(port, ((1 << port->ntxqs) - 1), thread); |
| 69 | ++ } |
| 70 | ++#endif |
| 71 | + /* Check number of available descriptors */ |
| 72 | + if (mvpp2_aggr_desc_num_check(port, aggr_txq, frags) || |
| 73 | + mvpp2_txq_reserved_desc_num_proc(port, txq, txq_pcpu, frags)) { |
| 74 | +@@ -5778,7 +5801,11 @@ static const struct net_device_ops mvpp2_netdev_ops = { |
| 75 | + .ndo_start_xmit = mvpp2_tx, |
| 76 | + .ndo_set_rx_mode = mvpp2_set_rx_mode, |
| 77 | + .ndo_set_mac_address = mvpp2_set_mac_address, |
| 78 | ++#ifdef CONFIG_NETMAP |
| 79 | ++ .ndo_change_mtu = mvpp2_netmap_change_mtu, |
| 80 | ++#else |
| 81 | + .ndo_change_mtu = mvpp2_change_mtu, |
| 82 | ++#endif |
| 83 | + .ndo_get_stats64 = mvpp2_get_stats64, |
| 84 | + .ndo_eth_ioctl = mvpp2_ioctl, |
| 85 | + .ndo_vlan_rx_add_vid = mvpp2_vlan_rx_add_vid, |
| 86 | +@@ -7088,6 +7115,9 @@ static void mvpp2_port_remove(struct mvpp2_port *port) |
| 87 | + { |
| 88 | + int i; |
| 89 | + |
| 90 | ++#ifdef CONFIG_NETMAP |
| 91 | ++ mvpp2_netmap_detach(port); |
| 92 | ++#endif /* CONFIG_NETMAP */ |
| 93 | + unregister_netdev(port->dev); |
| 94 | + if (port->phylink) |
| 95 | + phylink_destroy(port->phylink); |
| 96 | +@@ -7691,6 +7721,14 @@ static int mvpp2_probe(struct platform_device *pdev) |
| 97 | + mvpp2_dbgfs_init(priv, pdev->name); |
| 98 | + |
| 99 | + platform_set_drvdata(pdev, priv); |
| 100 | ++#ifdef CONFIG_NETMAP |
| 101 | ++ i = 0; |
| 102 | ++ device_for_each_child_node_scoped(&pdev->dev, port_fwnode) { |
| 103 | ++ if (priv->port_list[i]) |
| 104 | ++ mvpp2_netmap_attach(priv->port_list[i]); |
| 105 | ++ i++; |
| 106 | ++ } |
| 107 | ++#endif /* CONFIG_NETMAP */ |
| 108 | + return 0; |
| 109 | + |
| 110 | + err_port_probe: |
0 commit comments