From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30046.outbound.protection.outlook.com [40.107.3.46]) by dpdk.org (Postfix) with ESMTP id 0BCA92BD3 for ; Tue, 2 Oct 2018 12:34:12 +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=WtIFuMyYhPWWafZWRQB8v0bzhkTfducP2pdJwMVmA2Y=; b=aIZZfHAnyf6A6DkT09d9FEezYUDH84EQC1nIrFRE3g/8E7kBHIuDyBnMGPxz58XUfGsrijGKzKGDFBlOQv1/li1oYM/dCXm0ZxikEnJbVuvM58jHH1m6ZnDqJdKh1vHS34zQJDoe1s3IGDyWr1hLB3WGtOb0nElJoR1n+nzdxVM= Received: from DB5PR05MB1254.eurprd05.prod.outlook.com (10.162.157.140) by DB5PR05MB1094.eurprd05.prod.outlook.com (10.161.240.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Tue, 2 Oct 2018 10:34:10 +0000 Received: from DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5]) by DB5PR05MB1254.eurprd05.prod.outlook.com ([fe80::3516:b329:5c35:51a5%2]) with mapi id 15.20.1185.024; Tue, 2 Oct 2018 10:34:10 +0000 From: Raslan Darawsheh To: "keith.wiles@intel.com" CC: Thomas Monjalon , "dev@dpdk.org" , Shahaf Shuler , Raslan Darawsheh , Ori Kam Thread-Topic: [PATCH v4 1/2] net/tap: change queue fd to be pointers to process private Thread-Index: AQHUWjt0dw8l8YPcvEq/wkRGEIGjcQ== Date: Tue, 2 Oct 2018 10:34:10 +0000 Message-ID: <1538476438-20891-1-git-send-email-rasland@mellanox.com> References: <1538047196-13789-2-git-send-email-rasland@mellanox.com> In-Reply-To: <1538047196-13789-2-git-send-email-rasland@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-clientproxiedby: AM4PR05CA0018.eurprd05.prod.outlook.com (2603:10a6:205::31) To DB5PR05MB1254.eurprd05.prod.outlook.com (2a01:111:e400:51cc::12) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5PR05MB1094; 6:VFZ7mb1k9J76Cy1e7+SZ3ONsc8kD7zNHjLmIJGXzXY8T0gAKaOVkCNH76+2nLwhrpeclDboPxwdycmfB5wAeCVUKn4/AZpEbZXd4wvWdhB5PtCxBi9qLjqedQPCCM6vcdUZbU1Nd23h3Tk56IfN3EZn22iDW8GNEpRteogS/GU26vjZc06L9zWaHfNLtF4Pf85enYjvYmIzjlIxfRAg4mmb6BUR9Ud/TGqT3VdMlCHWLbkpsNRxdwfRaTzoGYnCkOZEU4n4fcXmHAxDbAH0oTLfaGUEbUd5akBK/OKd9IShMxs9apY9gI21rWlIQHYcBLoLOjTwTvahiRxc0yoCbpmhLAjattZ3/qoDpm8QLrpdRGySHZ/i037stryOZ3ZP8qtTDdaYVT4pD6IuFgxY18S00DP0DUkSan/6Wm0h3ER4jtVz08dcPChkiq3g3C89ngwNsRWvKkyoEunxidB+H+g==; 5:Kx3GzlKM7+JIzii0Es33Iu+s0Rq08xeDc2V9G13WrJ+vPSLFKLu/JvI2dkSdqZ0DRe44pzFjmuIzyijx+hKpAoO01Iy7m11CPkjYTmGrgYAArWpcjCHqpKY1i6KB+DowefW55jLpgM4En87eh2qAndrbfpJLJC7GA4lGTb524Sg=; 7:skkyFTSvkyhUBeIARIVNvTi2k9g1nYlWGRtbIDZzmd510qdge+BIdRxM/oUtDXKTqJCtvTvSAjzVmgTOxnOLGX1QtA9VUK+4KbUkl0xOAPOn6eD+uHfIcF/kf7QI/vPOrXPA6wX0vSTyXEROCvIubfcqylV9bW8wlPECKRRFEJ5hbojYsNHWcBQlM13NhlrjkPfTYRpbypKGSyysHttCWdpj4yhsRhXoG23uNEDNPoEmzVhkICtavgpdIvESYLn0 x-ms-office365-filtering-correlation-id: faab30e9-c176-44d5-af5d-08d6285295e6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB5PR05MB1094; x-ms-traffictypediagnostic: DB5PR05MB1094: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr 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)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051); SRVR:DB5PR05MB1094; BCL:0; PCL:0; RULEID:; SRVR:DB5PR05MB1094; x-forefront-prvs: 0813C68E65 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(366004)(346002)(396003)(136003)(199004)(189003)(71190400001)(71200400001)(14454004)(256004)(6916009)(478600001)(8676002)(8936002)(50226002)(25786009)(3846002)(6116002)(97736004)(107886003)(4326008)(5660300001)(2906002)(53936002)(6486002)(14444005)(2900100001)(36756003)(6512007)(6436002)(5250100002)(2501003)(102836004)(106356001)(86362001)(446003)(105586002)(26005)(11346002)(2616005)(54906003)(186003)(5640700003)(486006)(52116002)(476003)(6506007)(386003)(99286004)(81156014)(76176011)(68736007)(81166006)(305945005)(7736002)(316002)(2351001)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR05MB1094; H:DB5PR05MB1254.eurprd05.prod.outlook.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-antispam-message-info: TWJ6naNeHRcZ2Rnfbz6wcBQyqFeYZP+ni6GzjVqEqfPgfGk9D2Jabc52Goc+a+1loATKJ+TYwWtShDrkovNdJPuXmEucM6nqUdjpj8XzXLo7AC0tVvKZgs2/y8cZDoqjLxiVj1HX3nebI6tweoX/kBcity16PIKAXjI/S9QweZJB1Wm+/dRc04WtGnh2hDIrfI1y2DjHw0YN6njOd8hzduMG+maazcYAcXa5V0VGMBKUyl+OlJWrp/Ugw4+NRwbhsQvx+fP7ZQG0Q0Mfdd3a0bI2gv26xppw6REK8EnJ/nZhA6kzK/WbgGKAB7gMxQY4mNA+nzb+fY6Ig3tuLP4R9rlesEX30TRqiICXBl+5VvA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: faab30e9-c176-44d5-af5d-08d6285295e6 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Oct 2018 10:34:10.3570 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1094 Subject: [dpdk-dev] [PATCH v4 1/2] net/tap: change queue fd to be pointers to 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: Tue, 02 Oct 2018 10:34:13 -0000 change the fds for the queues to be pointers and add new process private structure and make the queue fds point to it. Signed-off-by: Raslan Darawsheh --- drivers/net/tap/rte_eth_tap.c | 63 ++++++++++++++++++++++++---------------= ---- drivers/net/tap/rte_eth_tap.h | 9 +++++-- drivers/net/tap/tap_intr.c | 4 +-- 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index ad5ae98..8cc4552 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -64,6 +64,7 @@ =20 static struct rte_vdev_driver pmd_tap_drv; static struct rte_vdev_driver pmd_tun_drv; +static struct pmd_process_private *process_private; =20 static const char *valid_arguments[] =3D { ETH_TAP_IFACE_ARG, @@ -331,7 +332,7 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint1= 6_t nb_pkts) uint16_t data_off =3D rte_pktmbuf_headroom(mbuf); int len; =20 - len =3D readv(rxq->fd, *rxq->iovecs, + len =3D readv(*rxq->fd, *rxq->iovecs, 1 + (rxq->rxmode->offloads & DEV_RX_OFFLOAD_SCATTER ? rxq->nb_rx_desc : 1)); @@ -595,7 +596,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbuf= s, tap_tx_l4_cksum(l4_cksum, l4_phdr_cksum, l4_raw_cksum); =20 /* copy the tx frame data */ - n =3D writev(txq->fd, iovecs, j); + n =3D writev(*txq->fd, iovecs, j); if (n <=3D 0) break; (*num_packets)++; @@ -976,13 +977,13 @@ tap_dev_close(struct rte_eth_dev *dev) tap_flow_implicit_flush(internals, NULL); =20 for (i =3D 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { - if (internals->rxq[i].fd !=3D -1) { - close(internals->rxq[i].fd); - internals->rxq[i].fd =3D -1; + if (*internals->rxq[i].fd !=3D -1) { + close(*internals->rxq[i].fd); + *internals->rxq[i].fd =3D -1; } - if (internals->txq[i].fd !=3D -1) { - close(internals->txq[i].fd); - internals->txq[i].fd =3D -1; + if (*internals->txq[i].fd !=3D -1) { + close(*internals->txq[i].fd); + *internals->txq[i].fd =3D -1; } } =20 @@ -1007,9 +1008,9 @@ tap_rx_queue_release(void *queue) { struct rx_queue *rxq =3D queue; =20 - if (rxq && (rxq->fd > 0)) { - close(rxq->fd); - rxq->fd =3D -1; + if (rxq && rxq->fd && (*rxq->fd > 0)) { + close(*rxq->fd); + *rxq->fd =3D -1; rte_pktmbuf_free(rxq->pool); rte_free(rxq->iovecs); rxq->pool =3D NULL; @@ -1022,9 +1023,9 @@ tap_tx_queue_release(void *queue) { struct tx_queue *txq =3D queue; =20 - if (txq && (txq->fd > 0)) { - close(txq->fd); - txq->fd =3D -1; + if (txq && txq->fd && (*txq->fd > 0)) { + close(*txq->fd); + *txq->fd =3D -1; } } =20 @@ -1214,13 +1215,13 @@ tap_setup_queue(struct rte_eth_dev *dev, struct rte_gso_ctx *gso_ctx; =20 if (is_rx) { - fd =3D &rx->fd; - other_fd =3D &tx->fd; + fd =3D rx->fd; + other_fd =3D tx->fd; dir =3D "rx"; gso_ctx =3D NULL; } else { - fd =3D &tx->fd; - other_fd =3D &rx->fd; + fd =3D tx->fd; + other_fd =3D rx->fd; dir =3D "tx"; gso_ctx =3D &tx->gso_ctx; } @@ -1331,7 +1332,7 @@ tap_rx_queue_setup(struct rte_eth_dev *dev, } =20 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, *internals->rxq[rx_queue_id].fd); =20 return 0; =20 @@ -1371,7 +1372,7 @@ 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, *internals->txq[tx_queue_id].fd, txq->csum ? "on" : "off"); =20 return 0; @@ -1633,6 +1634,10 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, cha= r *tap_name, goto error_exit_nodev; } =20 + process_private =3D (struct pmd_process_private *) + rte_zmalloc_socket(tap_name, sizeof(struct pmd_process_private), + RTE_CACHE_LINE_SIZE, dev->device->numa_node); + pmd =3D dev->data->dev_private; pmd->dev =3D dev; snprintf(pmd->name, sizeof(pmd->name), "%s", tap_name); @@ -1669,8 +1674,10 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, cha= r *tap_name, /* Presetup the fds to -1 as being not valid */ pmd->ka_fd =3D -1; for (i =3D 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { - pmd->rxq[i].fd =3D -1; - pmd->txq[i].fd =3D -1; + process_private->rxq_fds[i] =3D -1; + process_private->txq_fds[i] =3D -1; + pmd->rxq[i].fd =3D &process_private->rxq_fds[i]; + pmd->txq[i].fd =3D &process_private->txq_fds[i]; } =20 if (pmd->type =3D=3D ETH_TUNTAP_TYPE_TAP) { @@ -2089,13 +2096,13 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) tap_nl_final(internals->nlsk_fd); } for (i =3D 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { - if (internals->rxq[i].fd !=3D -1) { - close(internals->rxq[i].fd); - internals->rxq[i].fd =3D -1; + if (*internals->rxq[i].fd !=3D -1) { + close(*internals->rxq[i].fd); + *internals->rxq[i].fd =3D -1; } - if (internals->txq[i].fd !=3D -1) { - close(internals->txq[i].fd); - internals->txq[i].fd =3D -1; + if (*internals->txq[i].fd !=3D -1) { + close(*internals->txq[i].fd); + *internals->txq[i].fd =3D -1; } } =20 diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h index 44e2773..4146f5c 100644 --- a/drivers/net/tap/rte_eth_tap.h +++ b/drivers/net/tap/rte_eth_tap.h @@ -46,7 +46,7 @@ struct rx_queue { struct rte_mempool *mp; /* Mempool for RX packets */ uint32_t trigger_seen; /* Last seen Rx trigger value */ uint16_t in_port; /* Port ID */ - int fd; + 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 */ @@ -56,7 +56,7 @@ struct rx_queue { }; =20 struct tx_queue { - int fd; + int *fd; int type; /* Type field - TUN|TAP */ uint16_t *mtu; /* Pointer to MTU from dev_data */ uint16_t csum:1; /* Enable checksum offloading */ @@ -92,6 +92,11 @@ struct pmd_internals { int ka_fd; /* keep-alive file descriptor */ }; =20 +struct pmd_process_private { + int rxq_fds[RTE_PMD_TAP_MAX_QUEUES]; + int txq_fds[RTE_PMD_TAP_MAX_QUEUES]; +}; + /* tap_intr.c */ =20 int tap_rx_intr_vec_set(struct rte_eth_dev *dev, int set); diff --git a/drivers/net/tap/tap_intr.c b/drivers/net/tap/tap_intr.c index fc59018..a4b212d 100644 --- a/drivers/net/tap/tap_intr.c +++ b/drivers/net/tap/tap_intr.c @@ -71,7 +71,7 @@ tap_rx_intr_vec_install(struct rte_eth_dev *dev) struct rx_queue *rxq =3D pmd->dev->data->rx_queues[i]; =20 /* Skip queues that cannot request interrupts. */ - if (!rxq || rxq->fd <=3D 0) { + if (!rxq || !rxq->fd || *rxq->fd <=3D 0) { /* Use invalid intr_vec[] index to disable entry. */ intr_handle->intr_vec[i] =3D RTE_INTR_VEC_RXTX_OFFSET + @@ -79,7 +79,7 @@ tap_rx_intr_vec_install(struct rte_eth_dev *dev) continue; } intr_handle->intr_vec[i] =3D RTE_INTR_VEC_RXTX_OFFSET + count; - intr_handle->efds[count] =3D rxq->fd; + intr_handle->efds[count] =3D *rxq->fd; count++; } if (!count) --=20 2.7.4