From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40127.outbound.protection.outlook.com [40.107.4.127]) by dpdk.org (Postfix) with ESMTP id 541811BF1B for ; Wed, 27 Jun 2018 14:04:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cgstowernetworks.onmicrosoft.com; s=selector1-cgstowernetworks-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qkZlWmXLwJulU0SrusRhiUoFcby4EYDWEpzmwIN3ZjA=; b=myvXDKiX25SlL0JlD0Q1V2Bb/s0SVvKQvOgci1wIqK3fIEoydElw7KTl5WZO799j9fdEMmlNf2UVmynBRj9iC8NLGraYkaST2Qf4EwnpcWfa8SGhzQnjG7Lv5S0u9f5TzYnClzH7ngb3aouHxR3i6Q5xlj7ccAW67Q69sXOol3g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ido@cgstowernetworks.com; Received: from localhost.localdomain (81.218.57.230) by VI1PR0901MB1294.eurprd09.prod.outlook.com (2603:10a6:800:1a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.884.23; Wed, 27 Jun 2018 12:04:11 +0000 From: ido goshen To: Ferruh Yigit , Bruce Richardson , John McNamara , Marko Kovacevic Cc: dev@dpdk.org, ido g Date: Wed, 27 Jun 2018 15:04:03 +0300 Message-Id: <1530101043-97249-1-git-send-email-ido@cgstowernetworks.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [81.218.57.230] X-ClientProxiedBy: VI1P18901CA0011.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::21) To VI1PR0901MB1294.eurprd09.prod.outlook.com (2603:10a6:800:1a::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 06094d70-150a-4344-8cc3-08d5dc261941 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(7021125)(8989117)(4534165)(7022125)(4603075)(4627221)(201702281549075)(8990107)(7048125)(7024125)(7027125)(7028125)(7023125)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR0901MB1294; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0901MB1294; 3:ITBrftw8VHDUd66X5cebpX2w5m41R3xyY2REAw/E46f9gR7Z4HBpUKOLP+UqIiHhWyVwjhHOzxiWAeqIa67N44Vo+StXkO//NQp1TzRpx7dLItjFHcUWRBpt8q11j/QezeDfHaQgN25DATNZ0aPsW4C9rmHXOuCkLAUVAvXgeta7oIYvJS9wXFYXL8Uu1m9hqtBtPP31Y63+LE6RSC3mMeDeIcqNYHrXjqJrM/y/xNa9wZO4g7QxdDi85GL+qAG2; 25:zcyRNQyP5ArOGMICteVQSGizkj1psizEHYarHVAHBWx+jNyzwcDmKtMY8S3jURKNLuAZr98XKwJKLP1kwi1q4IKGJF/veicU9oCFfQHhkeP/zBJvy3DPqyE+VLITHb99jn8s3afAJ9Xjp+++yjfyKtgN2U79Jrn7UcmoXfpVZEkZzgOalerzULz1aUynj13z6BJMHSVYUW6nSOR0xGhzZgvF9gAoAVqzYV8hjPCNNRLrTGceS6HAPtKHU4Wdg60SrUQhvLl1I3hrAg+hWKcWoAoDh7Ocz7X/72sT9uvazDb/bYTtYvdDZorGLnCPPJptymAQRbU0DmfAwNTEWr156g==; 31:+ieiY9RUqSoiyEqDg8pThLEn6t0DTQCOqnyor2v1OAfqQ+6OoKgAn948GXZnBZo0WtkED4fcJDjK6dr2RdtHGWFN3XkvgIodsUAVF6TdsI85k1k+OGtxSvORpUobfK7qaZT/fWkBbGH+2E6sp0uB+osiNquXTQgmMTC6wXyIcCy+QUr/TAC4RSFu00xZ4oViaISf3abpnpgTb0V7NVoqQ5HZlJZoCWUEIgHQIwjnF04= X-MS-TrafficTypeDiagnostic: VI1PR0901MB1294: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(149027)(150027)(6041310)(20161123558120)(20161123564045)(2016111802025)(20161123560045)(20161123562045)(6043046)(6072148)(201708071742011)(7699016); SRVR:VI1PR0901MB1294; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0901MB1294; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0901MB1294; 4:+59vm29udkYCpU6+EvXMtAED804m9+mHFhPIeEnr2B3k648xn4q5DeykuP/kugskHKMvH2ENHRnZ6MPBxk1kKHWDdKzGOeOig5s5QcPZpEMORevesHJ357Vt1oBDxr1s586gYIPvtv9EWJLuanxN4qgt8fw8LsQt7ZHQcpWvSZMcNm0YdT7rxekz5IV69GqKyAN7NzHUAnBXpjdhf8yp6CzLq+8sKUhH28JlhEK4FCXyFfBcyBuTfy3IW0nISJMwcgze+gTT05BwsGsMaNjCTw== X-Forefront-PRVS: 0716E70AB6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(396003)(346002)(136003)(39840400004)(366004)(376002)(189003)(199004)(2906002)(106356001)(105586002)(5660300001)(80792005)(97736004)(72206003)(52116002)(51416003)(53936002)(478600001)(26005)(16526019)(186003)(386003)(6506007)(476003)(486006)(110136005)(956004)(316002)(2616005)(16586007)(6666003)(25786009)(4326008)(47776003)(107886003)(81166006)(66066001)(68736007)(36756003)(50226002)(86152003)(6512007)(6116002)(3846002)(305945005)(7736002)(14444005)(86362001)(8936002)(8676002)(81156014)(50466002)(6486002)(48376002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0901MB1294; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cgstowernetworks.com does not designate permitted sender hosts) X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y+LMMfUQdpClJ/TUOcGObkvZvT2gtH5acWDQLuYOIXGvfcP?= =?us-ascii?Q?uvl5peXtjjo26ijQGkRYKdbVaz17NiVJ0wCYmuRMBpJBrXetz/BTYwTyI7ZB?= =?us-ascii?Q?YhHv5yj/3jpZmLGTCTNB88bQr338q4rEJaykgmaaMTZpZRMqFaXk145aQwno?= =?us-ascii?Q?GjYOeipBOrskiy1v5yh6Wxs+NXW+iAOruRUIfnsu7otiRrV4oX/PQCs6Vl0h?= =?us-ascii?Q?PtYLDZKKe67NaZTx5cKmodrGeup99CMVrpeU4lA89Er7zM0Z61zc+e1m86kq?= =?us-ascii?Q?loG0ZjVuFjKqQe2HkxwPsICB3uKEmTC2kN1JcYsDTPnZrk4j1vzjN9cZBWu1?= =?us-ascii?Q?1bCgD1Xc/n7U5JlgPHBYhF0KoWGfQebmcFocdDM7+mWibZUJBd8+wN2u9dg?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Antispam-Message-Info: 4GBbl26hPfxP5jjyJEWLOdncO26x2TeyGdutlGF7oXos8mw/Xw8DaTAFlkNqLPDjVVmuJK8D+wRqVhBrIAKHHUTVPj2FfuAnPOWi3PGzxQupZEKueRyDZHATvOpUVRv+veKcrBZePYok6WYvemMs0YGoVSUvpoCChLCDTF1d06BniyeoOlABcZ5esyymRNLgOiFUO61fMt9j12zMxfnuPbSoHbdGsRJbZWx88b9JQofdBpvY5FLB2iTLPb0UVdDNKpoZ5T3jnOgaojnsrrg9Yg9oWCZrlU8y5YTWTS8cW+vM5M19Qaijp0m1CHOyAzzZV61cPB7Sic3nh4HQ/9Vl6gJTanpn8GLJ4/P43W0SHWo= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0901MB1294; 6:mWcmabbSCbe3xFzerAoI89Ow2Ow+ePxnT7D1yG0NuOI+ad53QDAWw19pjJRT89fOWTk9aZRMUCJi0juhtk4Zb/TcMA1p96Yb1l5EoL1CCxShiAMFHIFBOloSm7MQG3zgit8bxb7U6KNWpxPraATIBZORPDPI2/0dxlJkbf77Oz1j6p05cgw9NA1yBFwfZ08dW20VzPK88XJY3QtQOtGTTfKaADsGWpVh/uzqX8Tb8hPn4noRw1I5tyhOTfVLglJzMKM5l7Jsrw8hyyvuTs5knRvuLca88fq/VTYmix1vSvvCcN7br4hZNC5sQRlcO1qs9EVwdcigciiTvod/vjqiFY2Ol8KUfldLCTRgHU5XcLPZCJ5mMiRE3mQWRTW6ycyR9sgU/+PavbuxC2me5YOZWivpBDnHK0KYLsKowCsQ4Jt4zYGOGSTy+f0IisIHnGcbBS8n6HezW8lTeSn8PUnSCg==; 5:KYokY1kfFOGy4yP7R6W+Shd3esUh0p0zkaWY3pDI+L7ZMg1OEdyJZDsRLMexVoe04VuSBp6z5ErcPMQ1LyICvmU58V/+kBzt1TVAe5MhRlDWsTX2KUtwoKRMU55uwnp2/Wz+Zr1benuvAdoerxu+YuRMfccPwo5aEV2+BV6ur6A=; 24:UQeE18rfLXnl/oqQ3ak0hxG2zFuQ3wfk4gJgSuZYTPXfSSnUtO/+4Q80I/HAF3J9TyBc6MfQkZGE4ATHBMmWixUTNulxSQT61kH6ok5wHZM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0901MB1294; 7:xSwQGbZhrxfnjPIdw7ygRwwhYP6T6JTAZ0C7veRWaqZ8vL2vyalPAu7OwxI2JJJcVU1NsY8YS9gCX7eoJO2/61pcIo6wQEuuJ5KbtjdQM/5KUckl+EEQzfFF/VHZ7BM8fDkRwsmxwxfoYrdR2BpxfSA03jcR/+UQKv8cxs6BUobhKg/9g0NLeBryxgmaVYgKKIZ9tg0FnKFcVGc4wwTxoIMIPjD+3vPHcH6k/0Mjsw/W9RfkGxdjUkzFIFS7k1YP X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2018 12:04:11.1668 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06094d70-150a-4344-8cc3-08d5dc261941 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fc9e9498-07e8-4b82-b4cf-365bba23cbbf X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0901MB1294 Subject: [dpdk-dev] [PATCH v3] net/pcap: rx_iface_in stream type support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2018 12:04:15 -0000 From: ido g Support rx of in direction packets only Useful for apps that also tx to eth_pcap ports in order to not see them echoed back in as rx when out direction is also captured Signed-off-by: ido g --- v3: * merge to updated dpdk-next-net code * pcap_ring doc update v2: * clean checkpatch warning doc/guides/nics/pcap_ring.rst | 25 ++++++++++++++++++++++- drivers/net/pcap/rte_eth_pcap.c | 45 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/doc/guides/nics/pcap_ring.rst b/doc/guides/nics/pcap_ring.rst index 7fd063c..6282be6 100644 --- a/doc/guides/nics/pcap_ring.rst +++ b/doc/guides/nics/pcap_ring.rst @@ -71,11 +71,19 @@ The different stream types are: tx_pcap=/path/to/file.pcap * rx_iface: Defines a reception stream based on a network interface name. - The driver reads packets coming from the given interface using the Linux kernel driver for that interface. + The driver reads packets from the given interface using the Linux kernel driver for that interface. + The driver captures both the incoming and outgoing packets on that interface. The value is an interface name. rx_iface=eth0 +* rx_iface_in: Defines a reception stream based on a network interface name. + The driver reads packets from the given interface using the Linux kernel driver for that interface. + The driver captures only the incoming packets on that interface. + The value is an interface name. + + rx_iface_in=eth0 + * tx_iface: Defines a transmission stream based on a network interface name. The driver sends packets to the given interface using the Linux kernel driver for that interface. The value is an interface name. @@ -122,6 +130,21 @@ Forward packets through two network interfaces: $RTE_TARGET/app/testpmd -l 0-3 -n 4 \ --vdev 'net_pcap0,iface=eth0' --vdev='net_pcap1;iface=eth1' +Enable 2 tx queues on a network interface: + +.. code-block:: console + + $RTE_TARGET/app/testpmd -l 0-3 -n 4 \ + --vdev 'net_pcap0,rx_iface=eth1,tx_iface=eth1,tx_iface=eth1' \ + -- --txq 2 + +Read only incoming packets from a network interface: + +.. code-block:: console + + $RTE_TARGET/app/testpmd -l 0-3 -n 4 \ + --vdev 'net_pcap0,rx_iface_in=eth1,tx_iface=eth1' + Using libpcap-based PMD with the testpmd Application ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index b21930b..9c31cef 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -26,6 +26,7 @@ #define ETH_PCAP_RX_PCAP_ARG "rx_pcap" #define ETH_PCAP_TX_PCAP_ARG "tx_pcap" #define ETH_PCAP_RX_IFACE_ARG "rx_iface" +#define ETH_PCAP_RX_IFACE_IN_ARG "rx_iface_in" #define ETH_PCAP_TX_IFACE_ARG "tx_iface" #define ETH_PCAP_IFACE_ARG "iface" @@ -83,6 +84,7 @@ struct pmd_devargs { ETH_PCAP_RX_PCAP_ARG, ETH_PCAP_TX_PCAP_ARG, ETH_PCAP_RX_IFACE_ARG, + ETH_PCAP_RX_IFACE_IN_ARG, ETH_PCAP_TX_IFACE_ARG, ETH_PCAP_IFACE_ARG, NULL @@ -739,6 +741,26 @@ struct pmd_devargs { } static inline int +set_iface_direction(const char *iface, + pcap_t *pcap, + pcap_direction_t direction) +{ + const char *direction_str = (direction == PCAP_D_IN) ? "IN" : "OUT"; + if (pcap_setdirection(pcap, direction) < 0) { + PMD_LOG(ERR, + "Setting %s pcap direction %s failed - %s\n", + iface, + direction_str, + pcap_geterr(pcap)); + return -1; + } + PMD_LOG(INFO, "Setting %s pcap direction %s\n", + iface, + direction_str); + return 0; +} + +static inline int open_iface(const char *key, const char *value, void *extra_args) { const char *iface = value; @@ -761,7 +783,17 @@ struct pmd_devargs { static inline int open_rx_iface(const char *key, const char *value, void *extra_args) { - return open_iface(key, value, extra_args); + int ret = open_iface(key, value, extra_args); + if (ret < 0) + return ret; + if (strcmp(key, ETH_PCAP_RX_IFACE_IN_ARG) == 0) { + struct pmd_devargs *pmd = extra_args; + unsigned int qid = pmd->num_of_queue - 1; + set_iface_direction(pmd->queue[qid].name, + pmd->queue[qid].pcap, + PCAP_D_IN); + } + return 0; } /* @@ -964,12 +996,18 @@ struct pmd_devargs { is_rx_pcap = rte_kvargs_count(kvlist, ETH_PCAP_RX_PCAP_ARG) ? 1 : 0; pcaps.num_of_queue = 0; - if (is_rx_pcap) + if (is_rx_pcap) { ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_PCAP_ARG, &open_rx_pcap, &pcaps); - else + } else { ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_IFACE_ARG, &open_rx_iface, &pcaps); + if (ret == 0) + ret = rte_kvargs_process(kvlist, + ETH_PCAP_RX_IFACE_IN_ARG, + &open_rx_iface, + &pcaps); + } if (ret < 0) goto free_kvlist; @@ -1035,6 +1073,7 @@ struct pmd_devargs { ETH_PCAP_RX_PCAP_ARG "= " ETH_PCAP_TX_PCAP_ARG "= " ETH_PCAP_RX_IFACE_ARG "= " + ETH_PCAP_RX_IFACE_IN_ARG "= " ETH_PCAP_TX_IFACE_ARG "= " ETH_PCAP_IFACE_ARG "="); -- 1.9.1