From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10106.outbound.protection.outlook.com [40.107.1.106]) by dpdk.org (Postfix) with ESMTP id BDA591B1FC for ; Sat, 16 Jun 2018 17:37:17 +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=YZcx0sbZh4MsrprgOm6UWgCFo5Q3uX9jiSE+BDVKYpw=; b=PLG1J+YQrWp37UCthVWVR2MNKXXbmW7SHkAMEVvL8j1Ig3y4XDMYwGL/MMA4c8PuUdbrTTPEKsOFOfmnatuG5YVjKxgkeRBcav+neQ/o4jA5OHWYynTpeuf4go+Zj8UJpkK7aDizjkIUbZWapQa1wDs6ecYdeMES7rkKH3i3x70= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ido@cgstowernetworks.com; Received: from ubuntu.localdomain (81.218.57.230) by HE1PR0901MB1436.eurprd09.prod.outlook.com (2603:10a6:3:54::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.19; Sat, 16 Jun 2018 15:37:15 +0000 From: ido goshen To: Ferruh Yigit Cc: dev@dpdk.org, ido goshen Date: Sat, 16 Jun 2018 18:36:37 +0300 Message-Id: <1529163397-88330-2-git-send-email-ido@cgstowernetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1529163397-88330-1-git-send-email-ido@cgstowernetworks.com> References: <1529163397-88330-1-git-send-email-ido@cgstowernetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [81.218.57.230] X-ClientProxiedBy: CWXP265CA0032.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:2d::20) To HE1PR0901MB1436.eurprd09.prod.outlook.com (2603:10a6:3:54::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2603e9e1-e3d2-45d5-63e6-08d5d39f0a3f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:HE1PR0901MB1436; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0901MB1436; 3:3AKO2NhfnuhwdQdys/e67IyjkWYTKdZwheqK2rgl6jw4ugf6WMFZPsURQVAsjogVZnT3y3uGJoxnsTZUILVZPhtUhNeSuox9yahE868eZg12l18IoXGouusk5pt1ZSTXc0VzJ/LtStqE8yRpoltMNmSLiGhQN4G8ViuvQ+/rMp0cFi16ZQAfwzpDljr8ifERLqoVK+7b+YoJ/5HZnXh5KhTEZF7RS+gVdAcLECF1boTHbu306I7OkPD1DnBok2bb; 25:qZ9E3tUdhODMVQjJFRxFLntGLDNz1oWIXSGzwWRyus7nGYLnGmZ97CkRVsgU477TaY1TwHYCnqthEjrC8cIq87bDBVTodxM0h/cMzEfw23q+0AYzprid9EqucjjdAa6/8TR+tLFhhQrBA1r/6NSexLq4aStR9oJOmeqLuu+w564FUdMR3S5czrkqiss4Ls+HN39OuOCEReDYvJRqyYcEBGnpdy5K9XJ09u9qKhKPBuKzG5l8jRLF4HXXbE+fcEbwWD0+if2cQCM3vUOkPAG5MoL+a7GX4JaesJ9EnfMKCT0Hr3Z44wMc5P+HpxjMHjNTsNkKo/4b0X5Do3EVzQbVGw==; 31:1/Rcw+qFdRrqsVvI9GQZDOqZNf+8XOABi3fYXDNE9rDoAdG1+G52xbVYFi0cjPHOcPOGNoFBYQwwKubG+gA43WCXcvgXIrQhygdk2OgfByH5L9/9VKPAPA6LqMajHlAptNQ/Si3rAJDtL/OAqA9fMFNwfYaYxvorcg9avH4XpuzkUhHa8xQ2q+qglVtyjAaNpKq67eivDrvXjw2ScDayXjnsKmOHdKye3z3LLCA6Pck= X-MS-TrafficTypeDiagnostic: HE1PR0901MB1436: 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)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:HE1PR0901MB1436; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0901MB1436; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0901MB1436; 4:7qnfEB41JTyo1J8DWGrpWZ5m0BC8OshfjRknWCUsPCafAicwZgfK75phFsjCXaEWSWvVwZmVXOcmKclUcvFB/4XlXPwgtJVxeu45UqzL2quzgqxbenn2cSLnLZDJcYgKeQh3aK74H9tuudw/qncJPlsBBktvwtArHdjWNgmoa36iFf2WR1szq+FeMI5pJjmJ9Dl/Emc65ZFCih233YDjob58UtUmAlxTzTIlOxvzPclf2QpRz6jnsn0/ZZLHRB+EcJRVyzWcep1WohJ3vyGOLQ== X-Forefront-PRVS: 0705EB1700 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(39830400003)(366004)(346002)(39380400002)(376002)(189003)(199004)(3846002)(6116002)(5660300001)(956004)(47776003)(476003)(2616005)(50226002)(16526019)(86152003)(16586007)(6916009)(186003)(6666003)(6486002)(7736002)(316002)(305945005)(68736007)(486006)(26005)(478600001)(52116002)(86362001)(36756003)(6512007)(51416003)(11346002)(106356001)(76176011)(105586002)(8936002)(72206003)(66066001)(25786009)(48376002)(386003)(50466002)(6506007)(53936002)(8676002)(107886003)(81166006)(97736004)(81156014)(4326008)(446003)(2906002)(80792005); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0901MB1436; H:ubuntu.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-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0901MB1436; 23:O5Y08cFDWsTg+ZPPf/aIo1ofG7m+HpcXAXgZWI0?= =?us-ascii?Q?h0uVnNN0EnMUMScslHo47yQqRRPLvQKZk51tnDF0rQln8uGW0lniv276v9rU?= =?us-ascii?Q?jkFC9cOwNx9C33JsqDOIcm5me7YEx0rjtrYGiqzowJDdvMjv/DaphgTx9gb4?= =?us-ascii?Q?k0MJdwuB7TVmTgwuRPzldCq+8qLglbmWFHSapoHdL9EtYjUGkPU1Ox9jNQp5?= =?us-ascii?Q?wRwv84HTA76jCKzPH89x4aWzjLsKmhvy7fiRRZoq+RfZZVnbhACGBWh97HGO?= =?us-ascii?Q?syqL096DYSeZyOx4dII6/2p7K+Sq3f0BIEDVsCN1G0zR8cRHiIGdo07mQKOu?= =?us-ascii?Q?7HpS8ILLI88e/Ss8Ilc3fgu7QD+JZPWfs9NPbwn6Dl/xQj8eavDmDvU69lAd?= =?us-ascii?Q?HItjqyym0BOzcIhebjgRpLHymVTccVSnJ57gL5jU9Xg5O2+PTWe4rgW8wSOc?= =?us-ascii?Q?z5Gu64T/fiaKJcyWTDJsy6WqPS480xFLlhyGK3SFifCdsBnSpCBj14J9GLLq?= =?us-ascii?Q?yCXBz3G1/+1PPrg/cKGC8SxAAgIt10PzLCpRJ4SUc0eLHzB1ZR9Gk0PkxgRw?= =?us-ascii?Q?s+FIROIuhGvQ8Iwde+jNJgIqamOZHL5lHl+z1PfrVwD0wCJTzgvDtbC2B4yv?= =?us-ascii?Q?5mazKPtW4e2n/wqlcQgEkFsR0bSd4gnt6qMKjOXzq2MQuyaZ3aCSmzQLS4ek?= =?us-ascii?Q?MMoVXvDNPC1yuhb+H0TaT8z57qmTRkcrvOgd3rF+2h9ljqw/tPLqQRsg6bz4?= =?us-ascii?Q?5eN+F5NObBbnIL7uVAwQ4bPVQ1NwPEU+0nP3mjRuXwC1OrppVR+Udu5LXztQ?= =?us-ascii?Q?mEojmtiiF8F+8Ff6++i3wMsgX7hIcvWmQKj7pG2wBl9HCHR9vb3iEC8eskfG?= =?us-ascii?Q?h6mUOaRrV+LkvqzK+ZwAdQ4KO4hD03H9OIb4EJfjIOAxGrF0yPxtwpk8Lmk8?= =?us-ascii?Q?/dQWzriezkOskXVR+j6+fcIRGsLU1/pcMaSPFP9KfkU/7O9m7wsOs3atHMPB?= =?us-ascii?Q?5QCejhpHvUqZV/qTHq05umqKBOg9GT7lozTG3BasKbTPQpsxQpQh8R7a/VQt?= =?us-ascii?Q?VkxaD4jRt3zRQUqoMX7tyWJE4yjuoxCYwmXRsJbXLTHvXQgyfoj+EEajO48S?= =?us-ascii?Q?sGJ8qm/+K1wGc+Bz2yT+y33Tg4eEkRsBffGpNdcW/apK3ksi+1xugTQCpGYO?= =?us-ascii?Q?0LgklggLS/Vej7R+fqXZI1OunPifB3aDiP4CJv6WmSMEWAczzz12Fgf+J69R?= =?us-ascii?Q?vgwFmDzxgnXnz5L5zvx81sUm3gvcvdywtJRu0Dqs3?= X-Microsoft-Antispam-Message-Info: JxRiN1F8jTvRhzjTzn5kMk3QgZgDy15brPjJ8RwLNc3vLwrlwKyOIubP7r0GLrTWF0cD6NG8Y97evvFpke8myGOdd1GO6CKisUplfz0kA3LICC5nVD9jZ1GRgxmsn4ANa/BqqoOSl9PI4/EVVUM0FGLXqZqjO4S6XSkH4P3X6aNLrugEszIFMPY/xMl4Uu1N X-Microsoft-Exchange-Diagnostics: 1; HE1PR0901MB1436; 6:vxbeDk4Lpq3HnfImZjfCq5lcUjBQA8KWEek2L42YYE3sblvGxu717sBFOi1LSL9ejDCyH8rkIetqRYxodBykRoPhGcu7pTqbVkBCOEWGZMW026iUB33m5k1a/hqrO8a3RbMHkoXHj6WbRq5/gTyODDpk6JLkn2WaJW5kaarJbmcHrcItZG0y4gue1ZXpkCb7abzOanx7OVo0tr6tG9dHy5r8Z8V/NgtEHR1ESusD2+FSNccgb2of9F28davdxoWXQWhu9b9gETP7GsX4yvHQqoFU8UuyLc8E7SAe7pAgw3Pxch/B4dicql8KZAXN/4PkHWq5KRBmB8CJoFribHKoeZ2F4L6LDIIADVBUl32cxQKCOP9OfdKevMun1Mc9y574B+5pfJlqPgCAR6Ii9e8gHz6OETleeUgzolfI2axH/mycAj0bXOi2vTsDilTMOlC/3NU/GZGe+lBxDanDAYGZOg==; 5:y/gs5XsMTSS9lOT6Db7IjlJ5zdTFfQhZFqtjVzGS7nzsBfLkeSxM9DPzSVWM1ptxI85wMIWe86UgYTHp7JPQfTnuQDYODDjTiChnVn+G5LTGdefDmk4INQurWscztF/E6srY7cDRhgaY5b8EAKH/BzRlbFDY9IYxsRV4iFuOOhU=; 24:6WWxEG10qg72Jw4bRWe+IODdpMTeDchMIH5eyYbt5nlbmZyxC0ZEcJDfMBSYKX5cKkHNB/neBpGsHkZiZbBbd1sDz9eMLE+zhjeJWWXT24c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0901MB1436; 7:FgFZ3FRz4t/LkTw5+PgEXYCGo68JV2+TpJcrVXPx8PQ2AewZUk/NNICou2l7mm2c0xp0R39szJLpDqtUke2bJIFLSMF0DBrebCWHsuAvc8es7/nta8SaDril9yQymOYgjR1vp+nFx0RmVF1PGR1Fi3TlBrBosFAnQAtq8Ydd9fQVh0yWuxbbdbqGlgetUqlY4L9j9WBp/BgswHCfLbUCzwY8XfikG60nArF0r6P6vdfHKZb/XtSikY18eylzdxER X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2018 15:37:15.9983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2603e9e1-e3d2-45d5-63e6-08d5d39f0a3f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fc9e9498-07e8-4b82-b4cf-365bba23cbbf X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0901MB1436 X-Mailman-Approved-At: Sat, 16 Jun 2018 22:22:15 +0200 Subject: [dpdk-dev] [PATCH 2/2] net/pcap: duplicate code consolidation 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: Sat, 16 Jun 2018 15:37:18 -0000 Signed-off-by: ido goshen --- drivers/net/pcap/rte_eth_pcap.c | 58 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 444abbb..e63998b 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -658,6 +658,20 @@ struct pmd_devargs { .stats_reset = eth_stats_reset, }; +static int +add_queue(struct pmd_devargs *pmd, const char *name, const char *type, + pcap_t *pcap, pcap_dumper_t *dumper) +{ + if (pcap) + pmd->queue[pmd->num_of_queue].pcap = pcap; + if (dumper) + pmd->queue[pmd->num_of_queue].dumper = dumper; + pmd->queue[pmd->num_of_queue].name = name; + pmd->queue[pmd->num_of_queue].type = type; + pmd->num_of_queue++; + return 0; +} + /* * Function handler that opens the pcap file for reading a stores a * reference of it for use it later on. @@ -672,10 +686,7 @@ struct pmd_devargs { if (open_single_rx_pcap(pcap_filename, &pcap) < 0) return -1; - rx->queue[rx->num_of_queue].pcap = pcap; - rx->queue[rx->num_of_queue].name = pcap_filename; - rx->queue[rx->num_of_queue].type = key; - rx->num_of_queue++; + add_queue(rx, pcap_filename, key, pcap, NULL); return 0; } @@ -694,10 +705,7 @@ struct pmd_devargs { if (open_single_tx_pcap(pcap_filename, &dumper) < 0) return -1; - dumpers->queue[dumpers->num_of_queue].dumper = dumper; - dumpers->queue[dumpers->num_of_queue].name = pcap_filename; - dumpers->queue[dumpers->num_of_queue].type = key; - dumpers->num_of_queue++; + add_queue(dumpers, pcap_filename, key, NULL, dumper); return 0; } @@ -722,44 +730,36 @@ struct pmd_devargs { return 0; } -/* - * Opens a NIC for reading packets from it - */ static inline int -open_rx_iface(const char *key, const char *value, void *extra_args) +open_iface(const char *key, const char *value, void *extra_args) { const char *iface = value; - struct pmd_devargs *rx = extra_args; + struct pmd_devargs *pmd = extra_args; pcap_t *pcap = NULL; if (open_single_iface(iface, &pcap) < 0) return -1; - rx->queue[rx->num_of_queue].pcap = pcap; - rx->queue[rx->num_of_queue].name = iface; - rx->queue[rx->num_of_queue].type = key; - rx->num_of_queue++; + add_queue(pmd, iface, key, pcap, NULL); return 0; } /* + * Opens a NIC for reading packets from it + */ +static inline int +open_rx_iface(const char *key, const char *value, void *extra_args) +{ + return open_iface(key, value, extra_args); +} + +/* * Opens a NIC for writing packets to it */ static int open_tx_iface(const char *key, const char *value, void *extra_args) { - const char *iface = value; - struct pmd_devargs *tx = extra_args; - pcap_t *pcap; - - if (open_single_iface(iface, &pcap) < 0) - return -1; - tx->queue[tx->num_of_queue].pcap = pcap; - tx->queue[tx->num_of_queue].name = iface; - tx->queue[tx->num_of_queue].type = key; - tx->num_of_queue++; - - return 0; + return open_iface(key, value, extra_args); } static struct rte_vdev_driver pmd_pcap_drv; -- 1.9.1