From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id CCAC67E75 for ; Thu, 4 Dec 2014 22:45:10 +0100 (CET) Received: from uucp by smtp.tuxdriver.com with local-rmail (Exim 4.63) (envelope-from ) id 1XweCz-0005mc-LE for dev@dpdk.org; Thu, 04 Dec 2014 16:45:09 -0500 Received: from linville-x1.hq.tuxdriver.com (localhost.localdomain [127.0.0.1]) by linville-x1.hq.tuxdriver.com (8.14.8/8.14.6) with ESMTP id sB4Lh6GA009469 for ; Thu, 4 Dec 2014 16:43:06 -0500 Received: (from linville@localhost) by linville-x1.hq.tuxdriver.com (8.14.8/8.14.8/Submit) id sB4Lh5tI009468 for dev@dpdk.org; Thu, 4 Dec 2014 16:43:05 -0500 X-Authentication-Warning: linville-x1.hq.tuxdriver.com: linville set sender to linville@tuxdriver.com using -f From: "John W. Linville" To: dev@dpdk.org Date: Thu, 4 Dec 2014 16:42:05 -0500 Message-Id: <1417729325-9410-1-git-send-email-linville@tuxdriver.com> X-Mailer: git-send-email 1.9.3 Subject: [dpdk-dev] [PATCH] librte_pmd_af_packet: add compile-time checks for kernel-specific options X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2014 21:45:11 -0000 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 --- lib/librte_pmd_af_packet/rte_eth_af_packet.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 3b5bd5840f51..d0fb3eb32e44 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 */ -- 1.9.3