summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2014-12-04 16:42:05 -0500
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-12-05 22:09:23 +0100
commita3a03e13a6b2e33efeae2ae99a63159193981a7a (patch)
tree8ced686743a7593a4b7a576a9a39fa6fdd86f96a
parent3e7b87dddbbf9c6bc27fcb7bbce41618853ad678 (diff)
downloaddpdk-a3a03e13a6b2e33efeae2ae99a63159193981a7a.zip
dpdk-a3a03e13a6b2e33efeae2ae99a63159193981a7a.tar.gz
dpdk-a3a03e13a6b2e33efeae2ae99a63159193981a7a.tar.xz
af_packet: add compile-time checks for kernel-specific options
This allows the PMD to compile with kernels that don't support the options in question. The "#if defined(...)" lines are a bit ugly, but I don't know of any better way to accomplish the task. Signed-off-by: John W. Linville <linville@tuxdriver.com> Acked-by: Neil Horman <nhorman@tuxdriver.com>
-rw-r--r--config/common_linuxapp2
-rw-r--r--lib/librte_pmd_af_packet/rte_eth_af_packet.c16
2 files changed, 13 insertions, 5 deletions
diff --git a/config/common_linuxapp b/config/common_linuxapp
index 02db43d..2f9643b 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -224,7 +224,7 @@ CONFIG_RTE_LIBRTE_PMD_BOND=y
#
# Compile software PMD backed by AF_PACKET sockets (Linux only)
#
-CONFIG_RTE_LIBRTE_PMD_AF_PACKET=n
+CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y
#
# Compile Xen PMD
diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
index 3b5bd58..d0fb3eb 100644
--- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c
+++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c
@@ -444,9 +444,9 @@ rte_pmd_init_internals(const char *name,
struct tpacket_req *req;
struct pkt_rx_queue *rx_queue;
struct pkt_tx_queue *tx_queue;
- int rc, tpver, discard, bypass;
+ int rc, qsockfd, tpver, discard;
unsigned int i, q, rdsize;
- int qsockfd, fanout_arg;
+ int fanout_arg __rte_unused, bypass __rte_unused;
for (k_idx = 0; k_idx < kvlist->count; k_idx++) {
pair = &kvlist->pairs[k_idx];
@@ -519,9 +519,13 @@ rte_pmd_init_internals(const char *name,
sockaddr.sll_protocol = htons(ETH_P_ALL);
sockaddr.sll_ifindex = (*internals)->if_index;
+#if defined(PACKET_FANOUT)
fanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff;
- fanout_arg |= (PACKET_FANOUT_HASH | PACKET_FANOUT_FLAG_DEFRAG |
- PACKET_FANOUT_FLAG_ROLLOVER) << 16;
+ fanout_arg |= (PACKET_FANOUT_HASH | PACKET_FANOUT_FLAG_DEFRAG) << 16;
+#if defined(PACKET_FANOUT_FLAG_ROLLOVER)
+ fanout_arg |= PACKET_FANOUT_FLAG_ROLLOVER << 16;
+#endif
+#endif
for (q = 0; q < nb_queues; q++) {
/* Open an AF_PACKET socket for this queue... */
@@ -553,6 +557,7 @@ rte_pmd_init_internals(const char *name,
goto error;
}
+#if defined(PACKET_QDISC_BYPASS)
bypass = 1;
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_QDISC_BYPASS,
&bypass, sizeof(bypass));
@@ -563,6 +568,7 @@ rte_pmd_init_internals(const char *name,
pair->value);
goto error;
}
+#endif
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_RX_RING, req, sizeof(*req));
if (rc == -1) {
@@ -623,6 +629,7 @@ rte_pmd_init_internals(const char *name,
goto error;
}
+#if defined(PACKET_FANOUT)
rc = setsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT,
&fanout_arg, sizeof(fanout_arg));
if (rc == -1) {
@@ -631,6 +638,7 @@ rte_pmd_init_internals(const char *name,
"for %s\n", name, pair->value);
goto error;
}
+#endif
}
/* reserve an ethdev entry */