forked from luigirizzo/netmap
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
51 changed files
with
3,122 additions
and
582 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
diff --git a/igb/Makefile b/igb/Makefile | ||
index 924ae5b..0a5f720 100644 | ||
--- a/igb/Makefile | ||
+++ b/igb/Makefile | ||
@@ -7,9 +7,9 @@ ifneq ($(KERNELRELEASE),) | ||
# Makefile for the Intel(R) Gigabit Ethernet Linux Driver | ||
# | ||
|
||
-obj-$(CONFIG_IGB) += igb.o | ||
+obj-$(CONFIG_IGB) += igb$(NETMAP_DRIVER_SUFFIX).o | ||
|
||
-define igb-y | ||
+define igb$(NETMAP_DRIVER_SUFFIX)-y | ||
igb_main.o | ||
e1000_api.o | ||
igb_ethtool.o | ||
@@ -25,19 +25,19 @@ define igb-y | ||
e1000_82575.o | ||
e1000_i210.o | ||
endef | ||
-igb-y := $(strip ${igb-y}) | ||
+igb$(NETMAP_DRIVER_SUFFIX)-y := $(strip ${igb$(NETMAP_DRIVER_SUFFIX)-y}) | ||
|
||
-igb-${CONFIG_DEBUG_FS} += igb_debugfs.o | ||
+igb$(NETMAP_DRIVER_SUFFIX)-${CONFIG_DEBUG_FS} += igb_debugfs.o | ||
|
||
-igb-$(CONFIG_PTP_1588_CLOCK:m=y) += igb_ptp.o | ||
+igb$(NETMAP_DRIVER_SUFFIX)-$(CONFIG_PTP_1588_CLOCK:m=y) += igb_ptp.o | ||
|
||
|
||
-igb-y += kcompat.o | ||
+igb$(NETMAP_DRIVER_SUFFIX)-y += kcompat.o | ||
|
||
else # ifneq($(KERNELRELEASE),) | ||
# normal makefile | ||
|
||
-DRIVER := igb | ||
+DRIVER := igb$(NETMAP_DRIVER_SUFFIX) | ||
|
||
ifeq (,$(wildcard common.mk)) | ||
$(error Cannot find common.mk build rules) | ||
@@ -94,9 +94,12 @@ ccc: clean | ||
@+$(call devkernelbuild,modules,coccicheck MODE=report)) | ||
|
||
# Build manfiles | ||
-manfile: | ||
+manfile: ../$(DRIVER).$(MANSECTION) | ||
@gzip -c ../${DRIVER}.${MANSECTION} > ${DRIVER}.${MANSECTION}.gz | ||
|
||
+../$(DRIVER).$(MANSECTION): | ||
+ @touch $@ | ||
+ | ||
# Clean the module subdirectories | ||
clean: | ||
@+$(call devkernelbuild,clean) | ||
diff --git a/igb/igb_main.c b/igb/igb_main.c | ||
index a8ad07b..60568f1 100644 | ||
--- a/igb/igb_main.c | ||
+++ b/igb/igb_main.c | ||
@@ -237,6 +237,10 @@ static struct pci_error_handlers igb_err_handler = { | ||
static void igb_init_fw(struct igb_adapter *adapter); | ||
static void igb_init_dmac(struct igb_adapter *adapter, u32 pba); | ||
|
||
+#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) | ||
+#include <if_igb_netmap.h> | ||
+#endif | ||
+ | ||
static struct pci_driver igb_driver = { | ||
.name = igb_driver_name, | ||
.id_table = igb_pci_tbl, | ||
@@ -3180,6 +3184,10 @@ static int igb_probe(struct pci_dev *pdev, | ||
/* 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 IGB_DCA | ||
if (dca_add_requester(&pdev->dev) == E1000_SUCCESS) { | ||
adapter->flags |= IGB_FLAG_DCA_ENABLED; | ||
@@ -3385,6 +3393,10 @@ static void igb_remove(struct pci_dev *pdev) | ||
*/ | ||
igb_release_hw_control(adapter); | ||
|
||
+#ifdef DEV_NETMAP | ||
+ netmap_detach(netdev); | ||
+#endif /* DEV_NETMAP */ | ||
+ | ||
unregister_netdev(netdev); | ||
|
||
igb_clear_interrupt_scheme(adapter); | ||
@@ -3797,6 +3809,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter, | ||
|
||
txdctl |= E1000_TXDCTL_QUEUE_ENABLE; | ||
E1000_WRITE_REG(hw, E1000_TXDCTL(reg_idx), txdctl); | ||
+#ifdef DEV_NETMAP | ||
+ igb_netmap_configure_tx_ring(adapter, reg_idx); | ||
+#endif /* DEV_NETMAP */ | ||
} | ||
|
||
/** | ||
@@ -7477,6 +7492,11 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) | ||
if (test_bit(__IGB_DOWN, &adapter->state)) | ||
return true; | ||
|
||
+#ifdef DEV_NETMAP | ||
+ if (netmap_tx_irq(tx_ring->netdev, tx_ring->queue_index)) | ||
+ return true; /* cleaned ok */ | ||
+#endif /* DEV_NETMAP */ | ||
+ | ||
tx_buffer = &tx_ring->tx_buffer_info[i]; | ||
tx_desc = IGB_TX_DESC(tx_ring, i); | ||
i -= tx_ring->count; | ||
@@ -8493,6 +8513,11 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget) | ||
unsigned int total_bytes = 0, total_packets = 0; | ||
u16 cleaned_count = igb_desc_unused(rx_ring); | ||
|
||
+#ifdef DEV_NETMAP | ||
+ if (netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &total_packets)) | ||
+ return true; | ||
+#endif /* DEV_NETMAP */ | ||
+ | ||
do { | ||
struct igb_rx_buffer *rx_buffer; | ||
union e1000_adv_rx_desc *rx_desc; | ||
@@ -8812,6 +8837,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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
diff --git a/ixgbe/Makefile b/ixgbe/Makefile | ||
index e613859..8ca5eaa 100644 | ||
--- a/ixgbe/Makefile | ||
+++ b/ixgbe/Makefile | ||
@@ -7,9 +7,9 @@ ifneq ($(KERNELRELEASE),) | ||
# Makefile for the Intel(R) 10GbE PCI Express Linux Network Driver | ||
# | ||
|
||
-obj-$(CONFIG_IXGBE) += ixgbe.o | ||
+obj-$(CONFIG_IXGBE) += ixgbe$(NETMAP_DRIVER_SUFFIX).o | ||
|
||
-define ixgbe-y | ||
+define ixgbe$(NETMAP_DRIVER_SUFFIX)-y | ||
ixgbe_main.o | ||
ixgbe_api.o | ||
ixgbe_common.o | ||
@@ -29,24 +29,24 @@ define ixgbe-y | ||
ixgbe_x540.o | ||
ixgbe_x550.o | ||
endef | ||
-ixgbe-y := $(strip ${ixgbe-y}) | ||
+ixgbe$(NETMAP_DRIVER_SUFFIX)-y := $(strip ${ixgbe$(NETMAP_DRIVER_SUFFIX)-y}) | ||
|
||
-ixgbe-${CONFIG_DCB} += ixgbe_dcb_nl.o | ||
+ixgbe$(NETMAP_DRIVER_SUFFIX)-${CONFIG_DCB} += ixgbe_dcb_nl.o | ||
|
||
-ixgbe-${CONFIG_DEBUG_FS} += ixgbe_debugfs.o | ||
+ixgbe$(NETMAP_DRIVER_SUFFIX)-${CONFIG_DEBUG_FS} += ixgbe_debugfs.o | ||
|
||
-ixgbe-${CONFIG_FCOE:m=y} += ixgbe_fcoe.o | ||
+ixgbe$(NETMAP_DRIVER_SUFFIX)-${CONFIG_FCOE:m=y} += ixgbe_fcoe.o | ||
|
||
-ixgbe-$(CONFIG_PTP_1588_CLOCK:m=y) += ixgbe_ptp.o | ||
+ixgbe$(NETMAP_DRIVER_SUFFIX)-$(CONFIG_PTP_1588_CLOCK:m=y) += ixgbe_ptp.o | ||
|
||
-ixgbe-${CONFIG_SYSFS} += ixgbe_sysfs.o | ||
+ixgbe$(NETMAP_DRIVER_SUFFIX)-${CONFIG_SYSFS} += ixgbe_sysfs.o | ||
|
||
-ixgbe-y += kcompat.o | ||
+ixgbe$(NETMAP_DRIVER_SUFFIX)-y += kcompat.o | ||
|
||
else # ifneq($(KERNELRELEASE),) | ||
# normal makefile | ||
|
||
-DRIVER := ixgbe | ||
+DRIVER := ixgbe$(NETMAP_DRIVER_SUFFIX) | ||
|
||
ifeq (,$(wildcard common.mk)) | ||
$(error Cannot find common.mk build rules) | ||
@@ -107,9 +107,12 @@ ccc: clean | ||
@+$(call devkernelbuild,modules,coccicheck MODE=report)) | ||
|
||
# Build manfiles | ||
-manfile: | ||
+manfile: ../$(DRIVER).$(MANSECTION) | ||
@gzip -c ../${DRIVER}.${MANSECTION} > ${DRIVER}.${MANSECTION}.gz | ||
|
||
+../$(DRIVER).$(MANSECTION): | ||
+ touch $@ | ||
+ | ||
# Clean the module subdirectories | ||
clean: | ||
@+$(call devkernelbuild,clean) | ||
diff --git a/ixgbe/ixgbe_main.c b/ixgbe/ixgbe_main.c | ||
index a6971c3..6cee6ed 100644 | ||
--- a/ixgbe/ixgbe_main.c | ||
+++ b/ixgbe/ixgbe_main.c | ||
@@ -706,6 +706,23 @@ struct ixgbe_adapter *adapter = netdev_priv(netdev); | ||
} | ||
} | ||
|
||
+#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE) | ||
+/* | ||
+ * The #ifdef DEV_NETMAP / #endif blocks in this file are meant to | ||
+ * be a reference on how to implement netmap support in a driver. | ||
+ * Additional comments are in ixgbe_netmap_linux.h . | ||
+ * | ||
+ * The code is originally developed on FreeBSD and in the interest | ||
+ * of maintainability we try to limit differences between the two systems. | ||
+ * | ||
+ * <ixgbe_netmap_linux.h> contains functions for netmap support | ||
+ * that extend the standard driver. | ||
+ * It also defines DEV_NETMAP so further conditional sections use | ||
+ * that instead of CONFIG_NETMAP | ||
+ */ | ||
+#include <ixgbe_netmap_linux.h> | ||
+#endif | ||
+ | ||
/** | ||
* ixgbe_clean_tx_irq - Reclaim resources after transmit completes | ||
* @q_vector: structure containing interrupt and ring information | ||
@@ -725,6 +742,17 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, | ||
if (test_bit(__IXGBE_DOWN, &adapter->state)) | ||
return true; | ||
|
||
+#ifdef DEV_NETMAP | ||
+ /* | ||
+ * In netmap mode, all the work is done in the context | ||
+ * of the client thread. Interrupt handlers only wake up | ||
+ * clients, which may be sleeping on individual rings | ||
+ * or on a global resource for all rings. | ||
+ */ | ||
+ if (netmap_tx_irq(adapter->netdev, tx_ring->queue_index) != NM_IRQ_PASS) | ||
+ return true; | ||
+#endif /* DEV_NETMAP */ | ||
+ | ||
tx_buffer = &tx_ring->tx_buffer_info[i]; | ||
tx_desc = IXGBE_TX_DESC(tx_ring, i); | ||
i -= tx_ring->count; | ||
@@ -2195,6 +2223,16 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, | ||
xdp.rxq = &rx_ring->xdp_rxq; | ||
#endif | ||
|
||
+#ifdef DEV_NETMAP | ||
+ /* | ||
+ * Same as the txeof routine: only wakeup clients on intr. | ||
+ */ | ||
+ int dummy, nm_irq; | ||
+ nm_irq = netmap_rx_irq(rx_ring->netdev, rx_ring->queue_index, &dummy); | ||
+ if (nm_irq != NM_IRQ_PASS) | ||
+ return (nm_irq == NM_IRQ_RESCHED) ? budget : 1; | ||
+#endif /* DEV_NETMAP */ | ||
+ | ||
while (likely(total_rx_packets < budget)) { | ||
union ixgbe_adv_rx_desc *rx_desc; | ||
struct ixgbe_rx_buffer *rx_buffer; | ||
@@ -3656,6 +3694,10 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, | ||
memset(ring->tx_buffer_info, 0, | ||
sizeof(struct ixgbe_tx_buffer) * ring->count); | ||
|
||
+#ifdef DEV_NETMAP | ||
+ txdctl = ixgbe_netmap_configure_tx_ring(adapter, reg_idx, txdctl); | ||
+#endif /* DEV_NETMAP */ | ||
+ | ||
/* enable queue */ | ||
IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(reg_idx), txdctl); | ||
|
||
@@ -4332,6 +4374,12 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, | ||
IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); | ||
|
||
ixgbe_rx_desc_queue_enable(adapter, ring); | ||
+ | ||
+#ifdef DEV_NETMAP | ||
+ if (ixgbe_netmap_configure_rx_ring(adapter, reg_idx)) | ||
+ return; | ||
+#endif /* DEV_NETMAP */ | ||
+ | ||
#ifdef HAVE_AF_XDP_ZC_SUPPORT | ||
if (ring->xsk_umem) | ||
ixgbe_alloc_rx_buffers_zc(ring, ixgbe_desc_unused(ring)); | ||
@@ -12900,6 +12948,10 @@ no_info_string: | ||
hw->mac.ops.setup_eee(hw, eee_enable); | ||
} | ||
|
||
+#ifdef DEV_NETMAP | ||
+ ixgbe_netmap_attach(adapter); | ||
+#endif /* DEV_NETMAP */ | ||
+ | ||
return 0; | ||
|
||
err_register: | ||
@@ -12955,6 +13007,11 @@ static void ixgbe_remove(struct pci_dev *pdev) | ||
return; | ||
|
||
netdev = adapter->netdev; | ||
+ | ||
+#ifdef DEV_NETMAP | ||
+ netmap_detach(netdev); | ||
+#endif /* DEV_NETMAP */ | ||
+ | ||
#ifdef HAVE_IXGBE_DEBUG_FS | ||
ixgbe_dbg_adapter_exit(adapter); | ||
|
Oops, something went wrong.