From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60086.outbound.protection.outlook.com [40.107.6.86]) by dpdk.org (Postfix) with ESMTP id B6E4B7EC7 for ; Wed, 17 Oct 2018 16:46:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ef1IfKFMTXEQQo08lT+eoqc9pchV6xlA0LG6MudgLgg=; b=ae7kmBeSxDT0yRSbPAT8svcrmzFWt1XdbXSVPiCfeOywvl9BGfbfVf24YdIlhas6jQcis89FoC5rjS8w4o6SVWHws2EgqZ3o5AfH5NRM9atRiLwFHjLwZNIz+ErrHVVruhDaPIOh3HdURb1RgliyKoeeqwDyOaiAaViT9An/Kyk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR05MB1259.eurprd05.prod.outlook.com (2a01:111:e400:588a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.23; Wed, 17 Oct 2018 14:46:07 +0000 From: Raslan Darawsheh To: keith.wiles@intel.com Cc: thomas@monjalon.net, dev@dpdk.org, shahafs@mellanox.com, rasland@mellanox.com, orika@mellanox.com, ferruh.yigit@intel.com Date: Wed, 17 Oct 2018 17:45:54 +0300 Message-Id: <1539787555-6920-2-git-send-email-rasland@mellanox.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539787555-6920-1-git-send-email-rasland@mellanox.com> References: <1539182356-15496-2-git-send-email-rasland@mellanox.com> <1539787555-6920-1-git-send-email-rasland@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: LO2P265CA0161.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::29) To HE1PR05MB1259.eurprd05.prod.outlook.com (2a01:111:e400:588a::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4248b863-3efa-459f-68f5-08d6343f4632 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:HE1PR05MB1259; X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1259; 3:xUk0Xi3QC452jbfq7LpCT5FDCTeFINBhLtEWQ9UWvlQyM/YvsaUxYs301eHXwMvXUyh8RWIZC4JRA1fNDBhjKAjCv6Stnkl16wkW1R09+sUmUIA9P6Nh3sg6k+7J5qswkvoD1apG1lCfvD57jGSUd70mG8YxtYPLIusVcSoHHs7JSqvj+2/krSQIoKdBiTOKG3Zb4DqM+X5NMl8/kEcCtNEUGvRlFekBvHcNdqZalRIMVoypeRH9QcCiC+B4wLLn; 25:wJtQGwME/Fok3CrPBZUD0YiHKeTVuI3yzqSbJBccnLsksbek99dpPqIdpDIrW2Zq04nZjJtefe5A3K95Fg3UEOsT1z3NHmkcOHFMWvo2v1jrxEod10SDgQggfJMs5O9p5xZIPmQsL8rSZ4RJqKYE9YF6TBlu1autl/C2zixFUcl8oEWeKMfhg7QYlZNfUePcIAKTcAb74rQtxoTGZ9DA36yk9hxGDTbakzIzIODDo259hvfwoPT5DxI6o7CcGUSHdjuisT6nyzjCkEpZzJOEfl5CQEYyzaTBc5vpxzibm7TFQ5gFgGdx99RwZQ/WWg7M57WhrZGU4swzC7A6sik5mw==; 31:RFydxhDkPlhIRNDXc/1PG0mqrs+DqwOru3pjzRGh//PL8UrTmWMujSNrITMfo5TsioItxka4R6xF4uyrrkycLGhSAn5FX1xKfNe1ZFW8tzHPcNNJMXk7XkEq/4klUzY2MRiZY0YYh8MQ4MR4u/mOJCsdhzNh1KZVeRcU1EoqjhBp/roycWeL8nTMlFCj13dfzZcsAfeM1eS7FA4WbaDfLHkwQACIaR3rA1ST5sOOfDA= X-MS-TrafficTypeDiagnostic: HE1PR05MB1259: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1259; 20:8DPpd2kZWk9COYSctHEjzf4/5xWA6pglOMbcpL9PwUPvGiVV8CSiVnsBFVDdu+OAWKzqUSEq7peNBsqZ2wGMxGukRtIq6A6LOAzRpClhX1ZX+IidZ4eV4lSL2tf2o+F9Cv6nP51GykTLfYRpKiJZIaQjgVK/gqs9Wcv6r0KQ21fRNhs5UopOCqkJAuNnBtMT7u9m9TgvM/cp/3/ot9dW2maubxhAMOrb5VCr7pTDFySf+/ZLP3K5D/Y3xDz630tbtwd77fOET6dJREvwlhSDp5K92hougTE6H9VnzUfmQY+Mo7RsVObh+4hMcZwGV8wsVBYsDCTFu2afrzAPK4/CTw+smOdG+1RaQ4By2rAhl6MCzypaqOnroqNUOsJ6rvpf6wN5RswpG2JiDlUONAKuNbQab0vIlpcb8Nd/qPJvnLMuyh5/LJqqUi979ZjVBfOR/HbR+G3ADdxL3D1cI4q498bSppShrCiX5/tiTTs7uLbk9TjzskUUv9GckNXijg+n; 4:QicV0sRhQYboQb7r+w5b+qx+Sc9VEwSKno/i9ZbGbveIFU40qCdYK10qvA+sqHuSxsxPHHuEcZOMANS7mu5p6TJdzpIbdzPYIdoZlFkoch8iWcnqTBCDPEi8U+cMVFiUaUcZoAA5sj5IvjbptHIK6tTjgttnSv0PEH4JE2373E+QV/gqb10xllSXz8vH0zofH6X4TGxr0zM8v7r6ddX5yyfATrGjLobilkJXAKuGOXWf/yIzbQY8pwgQLhzIhQNsPy5xFBb/yQbXYGIvPUbSLw== 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:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231355)(944501410)(4982022)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:HE1PR05MB1259; BCL:0; PCL:0; RULEID:; SRVR:HE1PR05MB1259; X-Forefront-PRVS: 08286A0BE2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(136003)(396003)(39860400002)(199004)(189003)(966005)(50466002)(48376002)(106356001)(50226002)(16526019)(105586002)(8936002)(186003)(2351001)(76176011)(956004)(446003)(52116002)(11346002)(4326008)(51416003)(25786009)(7696005)(21086003)(68736007)(2616005)(386003)(478600001)(8676002)(14444005)(97736004)(486006)(476003)(36756003)(33026002)(2361001)(5660300001)(7736002)(69596002)(81166006)(81156014)(305945005)(8886007)(316002)(55016002)(26005)(4744004)(16586007)(47776003)(6666004)(6916009)(66066001)(6306002)(86362001)(3846002)(53936002)(2906002)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR05MB1259; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR05MB1259; 23:L9EKYJvc9dndAtIEflN2/79M1x+RMVf6lrcfY1CMy?= =?us-ascii?Q?OnF56yCtHCRTeLhLmIfr5lKgvVrGd6kaC8XR/dHH0sj8ktcK76ybil9Q1IXj?= =?us-ascii?Q?O0U/Z1GKkTL28yUJ1oZbWI7ZUu2ZC/84lARtcH/PLJXuUpLy6BOxDCz79BZY?= =?us-ascii?Q?YZISY6sILOsnlBQJQHAskmzzWYyBo8XsWc2iyqbdDGBLuazGDWbMb7ISN1gS?= =?us-ascii?Q?bqTb9LPsed4UWMvu4Q42d34Ynh0bYpLULH4rm3csZUmZxxmcfRUaeWr3taJH?= =?us-ascii?Q?ya/8Y8XlWOzK6w99rvSK3w0fMt9Nuo7RA3dwj/z5Um8GCKZuDsKYYzw0n8mg?= =?us-ascii?Q?OtGc0gzmURtlJsQ9AzWqUshj8+Yuljt4UQ78mVLOREknOEN6TyfDTpAkgpBw?= =?us-ascii?Q?FwT3ys448/brgvdJYgDaHA6YuJ15I3bNRE662P0ubbFFqz8P0brhuphniaPc?= =?us-ascii?Q?+rF19x+EdUO0i+WEIwnZQMqWIpQXHJFcCw9vSrzZSNuq4QIwsZgBBeG0ji3R?= =?us-ascii?Q?8CB8EGNXYubje+8UoR8DaIVEBiXOwYGvPmwghpvOR3zAwYw9F5nUvL2wi6M9?= =?us-ascii?Q?MjuOfwaG5/hIl5ldtZYyZxoSi8TNNc+MWHwzGByi9tlqISmL70nQ2I+4ULCu?= =?us-ascii?Q?2qwNVxlNLkZp4yz6wET7dmvuphW4VGqJiGb+Ncr/ussG9ippwqrDINv76knN?= =?us-ascii?Q?J9JsvYv2wMfJOTPfNQp8Fphi3sWAb7vzHgj16/XA5HTwN9vyyyzt/tvsWkd6?= =?us-ascii?Q?0hIUV6BmomvP3NzOJUEsWL7BOb05Rt0btKH9HvR8bDTi1a+llFpWvIwdHY+y?= =?us-ascii?Q?uFY+WgnfMuPnkM2yKwnSWoq5vEZz8IVfWYitUNRTdJhb3iWG5G2amfZAkQEt?= =?us-ascii?Q?drV+i8p8Lm3hl6lFcKo8A8YIjPhBWzJfCzvD9ShD1MOEohcDSed9K5KBbSix?= =?us-ascii?Q?1HScDIwX09Sp9U3tNEC2hs4dQQwjrMJrKsmprg7U9za6auZXP9BXSc7EzaSC?= =?us-ascii?Q?43S6cwzzFl5BZOWWK62/OHv93NajcCuis1k6Jf+bIhDqDpA5j3Qw79hy5Ta3?= =?us-ascii?Q?C4UJijyo8UBNGBDYx5403GsUcnNhRt9MPn3SwTIIXhp2ffxpeFV/LaSw01sL?= =?us-ascii?Q?qLlI8yY3rng+ZgLcaY9YO6Q+XFGHXW3VWocTzQMSJVynktc+WIOnSVz6n+3O?= =?us-ascii?Q?N42sOZm5tBeqpeLzwId7AwPMibwhl137E7sONa0dUv3YR9DWo3AIkI7iMC14?= =?us-ascii?Q?gbGFEah3714t3qoa44FVCvzyDNPYatpgizbwp492yaUitzlABVntaHZInyMp?= =?us-ascii?Q?IqgARyoljCdA2986nrrvpLCEdSbYFmbe1FmC/LeBGPa?= X-Microsoft-Antispam-Message-Info: TyRUjRM+sfqvVtfOigEXLZiStT5KADsng+UOAp92jvrRWusTqq6JiDOInNOLO1qFaHEX2mOaXdwEbHw1EzE4wwjZ/kAgSOXi6jAWgERKyDmWRiJn/wIBObXwGr/gOgDXfDJTEYIkJfKB7jH7AwGgEZnwKiGtwGLVHdvokg9S8hCxR8HnQWFBViNMxszJG7PMk1CJyrte3SDvVdHyjI6CYTQZpoicKm3Cqvw7VWtZvVadlrItSkELdT7Kbo5FL5XUg1Zehd0RuzcG5sexRRBfozznmbKJU813swFjXV/33QGJW6zrvKYagzyRKNZajaiaGaXGXYqXCuKhNQrZi5IR6tv6wYYik0r0OGXV5yNmh+I= X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB1259; 6:v3RpFTASw9fxuWvbVZXuoYcPxqoWtatUWp5Z8GcLNBji/jluxwjsq5Pd7DCTyZ0mgCqf2XvxGVcDC/VyhL0gz6+eittZ6DS7YQUitKOahkoecgt+8HKciKdCPtnl6DbmaWY43oIBvg538OzUiVw616bLPlNI8zY50LhbKrfGJPoKBV6VZYm5O1yjMOmuCnu6KO8HlivbzaEpH5OHSaWMHNt5e348duo1GbIWzpSRM4H5KGWjhj4Y6AShZRUmeH21NbCKoHWWxtkkYt1hWOAQUqtz7zZ1n/WeH3eF3VNEE7ktvp9dXjNVkL/dBSSzGCnUv7vscXOjbv6TOaPQPkCHWYtmYdywOdf9lOBcz+c8t48qWVMAXblwBMn2q+ZbR12rM5VHcbpcB/HumElaLEyF183JVJEigLba8PSB2M7b78NmKwhxVOU3LD+ZBOqjMtb9hH4tLgcqN4WlEUBhwaTW4A==; 5:0vqqGprNSZXsXZa11yX3pI7IKR52OnAhA9gKQM24LUZk8oy6IRHxRzbKo5Bc/qOIhdcKmSS2OoHWnCRYepIo2eGg0dDmrO/fUFzfmYXpfqpD/a9B+X2TFu9Eyg9ci2s4yHLQiB4k31Phlnr/+TufmOAKm8tOXtTX3Qiy7dIqh6Y=; 7:V5AGsoybW//fupyd91Kh7/b+D0CdVVfOEcj5rqOBey39U+HprNtAROOFACoN0AOnBGl9ID0IFxdpX4YiMmFJBJ+rXWn4mbGiaj1tpl5+6Kxjvo6optBgurJx+wz3w/dzFo4UFZFzhYHCxNeTmO/gYksqO7LW4B9w4PuFlVWaC6q9eQ4ury/bIt9ss0wc4MeLFq6FCi2Z2/KoPyNI/1ZfnIUAOgO/WtMuGF7g2NK0dv1L711GKTi60Il3SK7pmb1y SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2018 14:46:07.5848 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4248b863-3efa-459f-68f5-08d6343f4632 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB1259 Subject: [dpdk-dev] [PATCH v8 2/3] net/tap: move fds of Rx/Tx queues to be in process private 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, 17 Oct 2018 14:46:11 -0000 fd's cannot be shared between processes, and each process need to have it's own fd's pointer. Signed-off-by: Raslan Darawsheh --- This patch has dependancy on the following patch http://patches.dpdk.org/patch/46185/ --- --- drivers/net/tap/rte_eth_tap.c | 93 +++++++++++++++++++++++++++++-------------- drivers/net/tap/rte_eth_tap.h | 7 +++- drivers/net/tap/tap_flow.c | 3 +- drivers/net/tap/tap_intr.c | 5 ++- 4 files changed, 73 insertions(+), 35 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index edfb7da..3372d54 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -315,6 +315,7 @@ static uint16_t pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) { struct rx_queue *rxq = queue; + struct pmd_process_private *process_private; uint16_t num_rx; unsigned long num_rx_bytes = 0; uint32_t trigger = tap_trigger; @@ -323,6 +324,7 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) return 0; if (trigger) rxq->trigger_seen = trigger; + process_private = rte_eth_devices[rxq->in_port].process_private; rte_compiler_barrier(); for (num_rx = 0; num_rx < nb_pkts; ) { struct rte_mbuf *mbuf = rxq->pool; @@ -331,9 +333,9 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) uint16_t data_off = rte_pktmbuf_headroom(mbuf); int len; - len = readv(rxq->fd, *rxq->iovecs, - 1 + - (rxq->rxmode->offloads & DEV_RX_OFFLOAD_SCATTER ? + len = readv(process_private->rxq_fds[rxq->queue_id], + *rxq->iovecs, + 1 + (rxq->rxmode->offloads & DEV_RX_OFFLOAD_SCATTER ? rxq->nb_rx_desc : 1)); if (len < (int)sizeof(struct tun_pi)) break; @@ -494,6 +496,9 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs, { int i; uint16_t l234_hlen; + struct pmd_process_private *process_private; + + process_private = rte_eth_devices[txq->out_port].process_private; for (i = 0; i < num_mbufs; i++) { struct rte_mbuf *mbuf = pmbufs[i]; @@ -595,7 +600,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs, tap_tx_l4_cksum(l4_cksum, l4_phdr_cksum, l4_raw_cksum); /* copy the tx frame data */ - n = writev(txq->fd, iovecs, j); + n = writev(process_private->txq_fds[txq->queue_id], iovecs, j); if (n <= 0) break; (*num_packets)++; @@ -970,19 +975,20 @@ tap_dev_close(struct rte_eth_dev *dev) { int i; struct pmd_internals *internals = dev->data->dev_private; + struct pmd_process_private *process_private = dev->process_private; tap_link_set_down(dev); tap_flow_flush(dev, NULL); tap_flow_implicit_flush(internals, NULL); for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { - if (internals->rxq[i].fd != -1) { - close(internals->rxq[i].fd); - internals->rxq[i].fd = -1; + if (process_private->rxq_fds[i] != -1) { + close(process_private->rxq_fds[i]); + process_private->rxq_fds[i] = -1; } - if (internals->txq[i].fd != -1) { - close(internals->txq[i].fd); - internals->txq[i].fd = -1; + if (process_private->txq_fds[i] != -1) { + close(process_private->txq_fds[i]); + process_private->txq_fds[i] = -1; } } @@ -1006,10 +1012,14 @@ static void tap_rx_queue_release(void *queue) { struct rx_queue *rxq = queue; + struct pmd_process_private *process_private; - if (rxq && (rxq->fd > 0)) { - close(rxq->fd); - rxq->fd = -1; + if (!rxq) + return; + process_private = rte_eth_devices[rxq->in_port].process_private; + if (process_private->rxq_fds[rxq->queue_id] > 0) { + close(process_private->rxq_fds[rxq->queue_id]); + process_private->rxq_fds[rxq->queue_id] = -1; rte_pktmbuf_free(rxq->pool); rte_free(rxq->iovecs); rxq->pool = NULL; @@ -1021,10 +1031,15 @@ static void tap_tx_queue_release(void *queue) { struct tx_queue *txq = queue; + struct pmd_process_private *process_private; + + if (!txq) + return; + process_private = rte_eth_devices[txq->out_port].process_private; - if (txq && (txq->fd > 0)) { - close(txq->fd); - txq->fd = -1; + if (process_private->txq_fds[txq->queue_id] > 0) { + close(process_private->txq_fds[txq->queue_id]); + process_private->txq_fds[txq->queue_id] = -1; } } @@ -1209,18 +1224,19 @@ tap_setup_queue(struct rte_eth_dev *dev, int *other_fd; const char *dir; struct pmd_internals *pmd = dev->data->dev_private; + struct pmd_process_private *process_private = dev->process_private; struct rx_queue *rx = &internals->rxq[qid]; struct tx_queue *tx = &internals->txq[qid]; struct rte_gso_ctx *gso_ctx; if (is_rx) { - fd = &rx->fd; - other_fd = &tx->fd; + fd = &process_private->rxq_fds[qid]; + other_fd = &process_private->txq_fds[qid]; dir = "rx"; gso_ctx = NULL; } else { - fd = &tx->fd; - other_fd = &rx->fd; + fd = &process_private->txq_fds[qid]; + other_fd = &process_private->rxq_fds[qid]; dir = "tx"; gso_ctx = &tx->gso_ctx; } @@ -1273,6 +1289,7 @@ tap_rx_queue_setup(struct rte_eth_dev *dev, struct rte_mempool *mp) { struct pmd_internals *internals = dev->data->dev_private; + struct pmd_process_private *process_private = dev->process_private; struct rx_queue *rxq = &internals->rxq[rx_queue_id]; struct rte_mbuf **tmp = &rxq->pool; long iov_max = sysconf(_SC_IOV_MAX); @@ -1332,7 +1349,8 @@ tap_rx_queue_setup(struct rte_eth_dev *dev, } TAP_LOG(DEBUG, " RX TUNTAP device name %s, qid %d on fd %d", - internals->name, rx_queue_id, internals->rxq[rx_queue_id].fd); + internals->name, rx_queue_id, + process_private->rxq_fds[rx_queue_id]); return 0; @@ -1352,6 +1370,7 @@ tap_tx_queue_setup(struct rte_eth_dev *dev, const struct rte_eth_txconf *tx_conf) { struct pmd_internals *internals = dev->data->dev_private; + struct pmd_process_private *process_private = dev->process_private; struct tx_queue *txq; int ret; uint64_t offloads; @@ -1374,7 +1393,8 @@ tap_tx_queue_setup(struct rte_eth_dev *dev, return -1; TAP_LOG(DEBUG, " TX TUNTAP device name %s, qid %d on fd %d csum %s", - internals->name, tx_queue_id, internals->txq[tx_queue_id].fd, + internals->name, tx_queue_id, + process_private->txq_fds[tx_queue_id], txq->csum ? "on" : "off"); return 0; @@ -1622,6 +1642,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, int numa_node = rte_socket_id(); struct rte_eth_dev *dev; struct pmd_internals *pmd; + struct pmd_process_private *process_private; struct rte_eth_dev_data *data; struct ifreq ifr; int i; @@ -1636,7 +1657,16 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, goto error_exit_nodev; } + process_private = (struct pmd_process_private *) + rte_zmalloc_socket(tap_name, sizeof(struct pmd_process_private), + RTE_CACHE_LINE_SIZE, dev->device->numa_node); + + if (process_private == NULL) { + TAP_LOG(ERR, "Failed to alloc memory for process private"); + return -1; + } pmd = dev->data->dev_private; + dev->process_private = process_private; pmd->dev = dev; snprintf(pmd->name, sizeof(pmd->name), "%s", tap_name); pmd->type = type; @@ -1672,8 +1702,8 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, /* Presetup the fds to -1 as being not valid */ pmd->ka_fd = -1; for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { - pmd->rxq[i].fd = -1; - pmd->txq[i].fd = -1; + process_private->rxq_fds[i] = -1; + process_private->txq_fds[i] = -1; } if (pmd->type == ETH_TUNTAP_TYPE_TAP) { @@ -2073,6 +2103,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; struct pmd_internals *internals; + struct pmd_process_private *process_private; int i; /* find the ethdev entry */ @@ -2081,6 +2112,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) return 0; internals = eth_dev->data->dev_private; + process_private = eth_dev->process_private; TAP_LOG(DEBUG, "Closing %s Ethernet device on numa %u", (internals->type == ETH_TUNTAP_TYPE_TAP) ? "TAP" : "TUN", @@ -2092,18 +2124,19 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) tap_nl_final(internals->nlsk_fd); } for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { - if (internals->rxq[i].fd != -1) { - close(internals->rxq[i].fd); - internals->rxq[i].fd = -1; + if (process_private->rxq_fds[i] != -1) { + close(process_private->rxq_fds[i]); + process_private->rxq_fds[i] = -1; } - if (internals->txq[i].fd != -1) { - close(internals->txq[i].fd); - internals->txq[i].fd = -1; + if (process_private->txq_fds[i] != -1) { + close(process_private->txq_fds[i]); + process_private->txq_fds[i] = -1; } } close(internals->ioctl_sock); rte_free(eth_dev->data->dev_private); + rte_free(eth_dev->process_private); rte_eth_dev_release_port(eth_dev); if (internals->ka_fd != -1) { diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h index 4502e24..dc3579a 100644 --- a/drivers/net/tap/rte_eth_tap.h +++ b/drivers/net/tap/rte_eth_tap.h @@ -47,7 +47,6 @@ struct rx_queue { uint32_t trigger_seen; /* Last seen Rx trigger value */ uint16_t in_port; /* Port ID */ uint16_t queue_id; /* queue ID*/ - int fd; struct pkt_stats stats; /* Stats for this RX queue */ uint16_t nb_rx_desc; /* max number of mbufs available */ struct rte_eth_rxmode *rxmode; /* RX features */ @@ -57,7 +56,6 @@ struct rx_queue { }; struct tx_queue { - int fd; int type; /* Type field - TUN|TAP */ uint16_t *mtu; /* Pointer to MTU from dev_data */ uint16_t csum:1; /* Enable checksum offloading */ @@ -95,6 +93,11 @@ struct pmd_internals { int ka_fd; /* keep-alive file descriptor */ }; +struct pmd_process_private { + int rxq_fds[RTE_PMD_TAP_MAX_QUEUES]; + int txq_fds[RTE_PMD_TAP_MAX_QUEUES]; +}; + /* tap_intr.c */ int tap_rx_intr_vec_set(struct rte_eth_dev *dev, int set); diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 0e01af6..3ba6945 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -1567,6 +1567,7 @@ tap_flow_isolate(struct rte_eth_dev *dev, struct rte_flow_error *error __rte_unused) { struct pmd_internals *pmd = dev->data->dev_private; + struct pmd_process_private *process_private = dev->process_private; /* normalize 'set' variable to contain 0 or 1 values */ if (set) @@ -1580,7 +1581,7 @@ tap_flow_isolate(struct rte_eth_dev *dev, * If netdevice is there, setup appropriate flow rules immediately. * Otherwise it will be set when bringing up the netdevice (tun_alloc). */ - if (!pmd->rxq[0].fd) + if (!process_private->rxq_fds[0]) return 0; if (set) { struct rte_flow *remote_flow; diff --git a/drivers/net/tap/tap_intr.c b/drivers/net/tap/tap_intr.c index fc59018..7af0010 100644 --- a/drivers/net/tap/tap_intr.c +++ b/drivers/net/tap/tap_intr.c @@ -51,6 +51,7 @@ static int tap_rx_intr_vec_install(struct rte_eth_dev *dev) { struct pmd_internals *pmd = dev->data->dev_private; + struct pmd_process_private *process_private = dev->process_private; unsigned int rxqs_n = pmd->dev->data->nb_rx_queues; struct rte_intr_handle *intr_handle = &pmd->intr_handle; unsigned int n = RTE_MIN(rxqs_n, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID); @@ -71,7 +72,7 @@ tap_rx_intr_vec_install(struct rte_eth_dev *dev) struct rx_queue *rxq = pmd->dev->data->rx_queues[i]; /* Skip queues that cannot request interrupts. */ - if (!rxq || rxq->fd <= 0) { + if (!rxq || process_private->rxq_fds[i] <= 0) { /* Use invalid intr_vec[] index to disable entry. */ intr_handle->intr_vec[i] = RTE_INTR_VEC_RXTX_OFFSET + @@ -79,7 +80,7 @@ tap_rx_intr_vec_install(struct rte_eth_dev *dev) continue; } intr_handle->intr_vec[i] = RTE_INTR_VEC_RXTX_OFFSET + count; - intr_handle->efds[count] = rxq->fd; + intr_handle->efds[count] = process_private->rxq_fds[i]; count++; } if (!count) -- 2.7.4