Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0c35d6a
original netmap drivers
giuseppelettieri Sep 14, 2013
a060073
enable/disable netmap on up/down
giuseppelettieri Sep 15, 2013
ef94f83
[ixgbe] netmap attach moved to probe
giuseppelettieri Sep 19, 2013
4167ad8
[ixgbe] enable/disable netmap on ifconfig up/down
giuseppelettieri Sep 19, 2013
b7cba1e
[e1000e] enable/disable netmap on if up/down
giuseppelettieri Sep 26, 2013
c2aa830
[igb] enable/disable netmap on if up/down
giuseppelettieri Oct 1, 2013
dfb22bd
[igb] added missing netmap enable
giuseppelettieri Oct 1, 2013
7f5b020
netmap adapter for virtio
giuseppelettieri Dec 11, 2013
838b171
[virtio-patch] use right multiqueue indexes
vmaffione Dec 19, 2013
9cd4a5e
netfront: patched xen-netfront driver for netmap
vmaffione Sep 13, 2014
d39e1d5
netfront-netmap: add support for tx handoff
vmaffione Sep 17, 2014
c728993
virtio: fix compilation
giuseppelettieri Oct 7, 2014
1867f26
[ixgbe] detach from netmap on removal
giuseppelettieri Sep 20, 2013
d435888
veth: add netmap support
vmaffione Jan 11, 2015
6e7ae27
i40e: attach/detach
giuseppelettieri Mar 2, 2015
c32154d
i40e: configure rings
giuseppelettieri Mar 3, 2015
90ac3f8
i40e: proper include of netmap header
giuseppelettieri Mar 3, 2015
b2edeb3
i40e: enable/disable rings
giuseppelettieri Mar 3, 2015
fbfbc59
i40e: irqs
giuseppelettieri Mar 3, 2015
081dd6d
removed all enable/disable rings
giuseppelettieri Sep 7, 2015
ddf2cfb
[ptnetmap/virtio] enable ptnetmap feature
stefano-garzarella Sep 16, 2015
c2bc1dd
i40e: remove useless check
giuseppelettieri Nov 18, 2015
f23fd7d
virtio-net: perform cleanup after netmap_detach()
vmaffione Nov 19, 2015
53cc59a
netmap: virtio-net: use NM_IRQ_* return codes
vmaffione Feb 16, 2016
ff303b6
netmap: ixgbe: use NM_IRQ_* return codes
vmaffione Feb 16, 2016
48e0c64
netmap: i40e: use NM_IRQ_* return codes
vmaffione Feb 16, 2016
06ae035
netmap: e1000: use NM_IRQ_* return codes
vmaffione Feb 17, 2016
eb98324
e1000: move name override before driver declaration
giuseppelettieri Nov 4, 2016
8150fc2
ixgbevf: initial patch
giuseppelettieri Apr 12, 2017
c51e6fe
igb: updated netmap_?x_irq() usages
giuseppelettieri Apr 26, 2017
520b303
ixgbe: move tx ring init to support tx head wb
giuseppelettieri Aug 4, 2017
fcbf778
ixgbevf: move tx init to support Tx head wb
giuseppelettieri Aug 8, 2017
cfcbdd4
ixgbe: call an ixgbe-specific detach function
giuseppelettieri Nov 2, 2017
56e0559
ixgebf: call a driver specific version of netmap_detach
giuseppelettieri Nov 3, 2017
fcb0ea6
i40e: hook for setting the rx buffer size
giuseppelettieri Dec 1, 2017
90fb7a1
vmxnet3: add netmap support
Feb 7, 2018
0a84e4c
e1000e: intercept jumbo RX frames
vmaffione Feb 21, 2018
edfef1a
e1000e: keep packet-split disabled with netmap
vmaffione Feb 22, 2018
3a7299c
e1000: intercept jumbo RX frames
vmaffione Feb 26, 2018
7c9d8e8
virtio: play well with xdp and napi_tx
giuseppelettieri Dec 17, 2020
48a8c71
stmmac: add netmap entry point functions
Feb 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions drivers/net/ethernet/intel/e1000/e1000_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ static const struct pci_error_handlers e1000_err_handler = {
.resume = e1000_io_resume,
};

#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE)
#include <if_e1000_netmap.h>
#endif

static struct pci_driver e1000_driver = {
.name = e1000_driver_name,
.id_table = e1000_pci_tbl,
Expand Down Expand Up @@ -400,6 +404,10 @@ static void e1000_configure(struct e1000_adapter *adapter)
e1000_configure_tx(adapter);
e1000_setup_rctl(adapter);
e1000_configure_rx(adapter);
#ifdef DEV_NETMAP
if (e1000_netmap_init_buffers(adapter))
return;
#endif /* DEV_NETMAP */
/* call E1000_DESC_UNUSED which always leaves
* at least 1 descriptor unused to make sure
* next_to_use != next_to_clean
Expand Down Expand Up @@ -1218,6 +1226,10 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

e1000_vlan_filter_on_off(adapter, false);

#ifdef DEV_NETMAP
e1000_netmap_attach(adapter);
#endif /* DEV_NETMAP */

/* print bus type/speed/width info */
e_info(probe, "(PCI%s:%dMHz:%d-bit) %pM\n",
((hw->bus_type == e1000_bus_type_pcix) ? "-X" : ""),
Expand Down Expand Up @@ -1282,6 +1294,10 @@ static void e1000_remove(struct pci_dev *pdev)

kfree(adapter->tx_ring);
kfree(adapter->rx_ring);

#ifdef DEV_NETMAP
netmap_detach(netdev);
#endif /* DEV_NETMAP */

if (hw->mac_type == e1000_ce4100)
iounmap(hw->ce4100_gbe_mdio_base_virt);
Expand Down Expand Up @@ -3866,6 +3882,10 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
unsigned int total_tx_bytes = 0, total_tx_packets = 0;
unsigned int bytes_compl = 0, pkts_compl = 0;

#ifdef DEV_NETMAP
if (netmap_tx_irq(netdev, 0) != NM_IRQ_PASS)
return 1; /* cleaned ok */
#endif /* DEV_NETMAP */
i = tx_ring->next_to_clean;
eop = tx_ring->buffer_info[i].next_to_watch;
eop_desc = E1000_TX_DESC(*tx_ring, eop);
Expand Down Expand Up @@ -4166,6 +4186,15 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
bool cleaned = false;
unsigned int total_rx_bytes = 0, total_rx_packets = 0;

#ifdef DEV_NETMAP
int nm_irq = netmap_rx_irq(netdev, 0, work_done);
if (nm_irq != NM_IRQ_PASS) {
if (nm_irq == NM_IRQ_RESCHED) {
*work_done = work_to_do;
}
return 1;
}
#endif /* DEV_NETMAP */
i = rx_ring->next_to_clean;
rx_desc = E1000_RX_DESC(*rx_ring, i);
buffer_info = &rx_ring->buffer_info[i];
Expand Down Expand Up @@ -4388,6 +4417,15 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
bool cleaned = false;
unsigned int total_rx_bytes = 0, total_rx_packets = 0;

#ifdef DEV_NETMAP
int nm_irq = netmap_rx_irq(netdev, 0, work_done);
if (nm_irq != NM_IRQ_PASS) {
if (nm_irq == NM_IRQ_RESCHED) {
*work_done = work_to_do;
}
return 1;
}
#endif /* DEV_NETMAP */
i = rx_ring->next_to_clean;
rx_desc = E1000_RX_DESC(*rx_ring, i);
buffer_info = &rx_ring->buffer_info[i];
Expand Down
31 changes: 31 additions & 0 deletions drivers/net/ethernet/intel/e1000e/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ static int e1000_desc_unused(struct e1000_ring *ring)
return ring->count + ring->next_to_clean - ring->next_to_use - 1;
}

#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE)
#include <if_e1000e_netmap.h>
#endif

/**
* e1000e_systim_to_hwtstamp - convert system time value to hw time stamp
* @adapter: board private structure
Expand Down Expand Up @@ -936,6 +940,10 @@ static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done,
bool cleaned = false;
unsigned int total_rx_bytes = 0, total_rx_packets = 0;

#ifdef DEV_NETMAP
if (netmap_rx_irq(netdev, 0, work_done))
return 1; /* seems to be ignored */
#endif /* DEV_NETMAP */
i = rx_ring->next_to_clean;
rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
Expand Down Expand Up @@ -1224,6 +1232,10 @@ static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring)
unsigned int total_tx_bytes = 0, total_tx_packets = 0;
unsigned int bytes_compl = 0, pkts_compl = 0;

#ifdef DEV_NETMAP
if (netmap_tx_irq(netdev, 0))
return 1; /* cleaned ok */
#endif /* DEV_NETMAP */
i = tx_ring->next_to_clean;
eop = tx_ring->buffer_info[i].next_to_watch;
eop_desc = E1000_TX_DESC(*tx_ring, eop);
Expand Down Expand Up @@ -1525,6 +1537,10 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_ring *rx_ring, int *work_done,
unsigned int total_rx_bytes = 0, total_rx_packets = 0;
struct skb_shared_info *shinfo;

#ifdef DEV_NETMAP
if (netmap_rx_irq(netdev, 0, work_done))
return 1; /* seems to be ignored */
#endif /* DEV_NETMAP */
i = rx_ring->next_to_clean;
rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
Expand Down Expand Up @@ -3126,6 +3142,10 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
adapter->rx_ps_pages = pages;
else
adapter->rx_ps_pages = 0;
#ifdef DEV_NETMAP
/* Keep packet-split disabled with netmap. */
adapter->rx_ps_pages = 0;
#endif /* DEV_NETMAP */

if (adapter->rx_ps_pages) {
u32 psrctl = 0;
Expand Down Expand Up @@ -3740,6 +3760,10 @@ static void e1000_configure(struct e1000_adapter *adapter)
e1000e_setup_rss_hash(adapter);
e1000_setup_rctl(adapter);
e1000_configure_rx(adapter);
#ifdef DEV_NETMAP
if (e1000e_netmap_init_buffers(adapter))
return;
#endif /* DEV_NETMAP */
adapter->alloc_rx_buf(rx_ring, e1000_desc_unused(rx_ring), GFP_KERNEL);
}

Expand Down Expand Up @@ -7314,6 +7338,9 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (err)
goto err_register;

#ifdef DEV_NETMAP
e1000_netmap_attach(adapter);
#endif /* DEV_NETMAP */
/* carrier off reporting is important to ethtool even BEFORE open */
netif_carrier_off(netdev);

Expand Down Expand Up @@ -7405,6 +7432,10 @@ static void e1000_remove(struct pci_dev *pdev)
kfree(adapter->tx_ring);
kfree(adapter->rx_ring);

#ifdef DEV_NETMAP
netmap_detach(netdev);
#endif /* DEV_NETMAP */

iounmap(adapter->hw.hw_addr);
if ((adapter->hw.flash_address) &&
(adapter->hw.mac.type < e1000_pch_spt))
Expand Down
28 changes: 28 additions & 0 deletions drivers/net/ethernet/intel/i40e/i40e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ MODULE_LICENSE("GPL");
MODULE_VERSION(DRV_VERSION);

static struct workqueue_struct *i40e_wq;
#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE)
#define NETMAP_I40E_MAIN
#include <i40e_netmap_linux.h>
#endif

/**
* i40e_allocate_dma_mem_d - OS specific memory alloc for shared code
Expand Down Expand Up @@ -2896,6 +2900,10 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring)
/* cache tail off for easier writes later */
ring->tail = hw->hw_addr + I40E_QTX_TAIL(pf_q);

#ifdef DEV_NETMAP
i40e_netmap_configure_tx_ring(ring);
#endif /* DEV_NETMAP */

return 0;
}

Expand Down Expand Up @@ -2949,6 +2957,10 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
/* set the prefena field to 1 because the manual says to */
rx_ctx.prefena = 1;

#ifdef DEV_NETMAP
i40e_netmap_preconfigure_rx_ring(ring, &rx_ctx);
#endif /* DEV_NETMAP */

/* clear the context in the HMC */
err = i40e_clear_lan_rx_queue_context(hw, pf_q);
if (err) {
Expand All @@ -2971,6 +2983,11 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
ring->tail = hw->hw_addr + I40E_QRX_TAIL(pf_q);
writel(0, ring->tail);

#ifdef DEV_NETMAP
if (i40e_netmap_configure_rx_ring(ring))
return 0;
#endif /* DEV_NETMAP */

i40e_alloc_rx_buffers(ring, I40E_DESC_UNUSED(ring));

return 0;
Expand Down Expand Up @@ -9519,6 +9536,11 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
return -ENODEV;
}

#ifdef DEV_NETMAP
if (vsi->netdev_registered)
netmap_detach(vsi->netdev);
#endif

uplink_seid = vsi->uplink_seid;
if (vsi->type != I40E_VSI_SRIOV) {
if (vsi->netdev_registered) {
Expand Down Expand Up @@ -9883,6 +9905,12 @@ struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
(vsi->type == I40E_VSI_VMDQ2)) {
ret = i40e_vsi_config_rss(vsi);
}

#ifdef DEV_NETMAP
if (vsi->netdev_registered)
i40e_netmap_attach(vsi);
#endif

return vsi;

err_rings:
Expand Down
16 changes: 16 additions & 0 deletions drivers/net/ethernet/intel/i40e/i40e_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#include "i40e.h"
#include "i40e_prototype.h"

#if defined(CONFIG_NETMAP) || defined (CONFIG_NETMAP_MODULE)
#include <i40e_netmap_linux.h>
#endif /* DEV_NETMAP */

static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size,
u32 td_tag)
{
Expand Down Expand Up @@ -665,6 +669,11 @@ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi,
unsigned int total_bytes = 0, total_packets = 0;
unsigned int budget = vsi->work_limit;

#ifdef DEV_NETMAP
if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index) != NM_IRQ_PASS)
return true;
#endif /* DEV_NETMAP */

tx_buf = &tx_ring->tx_bi[i];
tx_desc = I40E_TX_DESC(tx_ring, i);
i -= tx_ring->count;
Expand Down Expand Up @@ -1764,6 +1773,13 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
bool failure = false;

#ifdef DEV_NETMAP
int dummy;
if (rx_ring->netdev &&
netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &dummy) != NM_IRQ_PASS)
return 1;
#endif /* DEV_NETMAP */

while (likely(total_rx_packets < budget)) {
union i40e_rx_desc *rx_desc;
struct sk_buff *skb;
Expand Down
33 changes: 33 additions & 0 deletions drivers/net/ethernet/intel/igb/igb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ static int debug = -1;
module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");

#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE)
#include <if_igb_netmap.h>
#endif

struct igb_reg_info {
u32 ofs;
char *name;
Expand Down Expand Up @@ -2646,6 +2650,10 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* carrier off reporting is important to ethtool even BEFORE open */
netif_carrier_off(netdev);

#ifdef DEV_NETMAP
igb_netmap_attach(adapter);
#endif /* DEV_NETMAP */

#ifdef CONFIG_IGB_DCA
if (dca_add_requester(&pdev->dev) == 0) {
adapter->flags |= IGB_FLAG_DCA_ENABLED;
Expand Down Expand Up @@ -2914,6 +2922,10 @@ static void igb_remove(struct pci_dev *pdev)
wr32(E1000_DCA_CTRL, E1000_DCA_CTRL_DCA_MODE_DISABLE);
}
#endif
#ifdef DEV_NETMAP
netmap_detach(netdev);
#endif /* DEV_NETMAP */


/* Release control of h/w to f/w. If f/w is AMT enabled, this
* would have already happened in close and is redundant.
Expand Down Expand Up @@ -3400,6 +3412,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter,

txdctl |= E1000_TXDCTL_QUEUE_ENABLE;
wr32(E1000_TXDCTL(reg_idx), txdctl);
#ifdef DEV_NETMAP
igb_netmap_configure_tx_ring(adapter, reg_idx);
#endif /* DEV_NETMAP */
}

/**
Expand Down Expand Up @@ -6645,6 +6660,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector, int napi_budget)

if (test_bit(__IGB_DOWN, &adapter->state))
return true;
#ifdef DEV_NETMAP
if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index) != NM_IRQ_PASS)
return true; /* cleaned ok */
#endif /* DEV_NETMAP */

tx_buffer = &tx_ring->tx_buffer_info[i];
tx_desc = IGB_TX_DESC(tx_ring, i);
Expand Down Expand Up @@ -7153,6 +7172,15 @@ static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget)
unsigned int total_bytes = 0, total_packets = 0;
u16 cleaned_count = igb_desc_unused(rx_ring);

#ifdef DEV_NETMAP
/*
* Same as the txeof routine: only wakeup clients on intr.
*/
int nm_irq;
nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets);
if (nm_irq != NM_IRQ_PASS)
return (nm_irq == NM_IRQ_RESCHED) ? budget : 1;
#endif /* DEV_NETMAP */
while (likely(total_packets < budget)) {
union e1000_adv_rx_desc *rx_desc;

Expand Down Expand Up @@ -7270,6 +7298,11 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count)
struct igb_rx_buffer *bi;
u16 i = rx_ring->next_to_use;

#ifdef DEV_NETMAP
if (igb_netmap_configure_rx_ring(rx_ring))
return;
#endif /* DEV_NETMAP */

/* nothing to do */
if (!cleaned_count)
return;
Expand Down
Loading