From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0063.outbound.protection.outlook.com [104.47.1.63]) by dpdk.org (Postfix) with ESMTP id AA3621B014 for ; Thu, 7 Jun 2018 14:30:04 +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=4lNO+USZTeF1ihL+v6n5sLa8Fw6cObuJ1pti6cNofUs=; b=h8zE2z/hYXoEe36WzSYsPynJWtkUBCnscuNMDbBfhx/z68tsKxe+e+Q4xpFaNSHqHkTIgbp8XK4LDd1hoZUcVPVEwF9dfSGGxvotQjQaUjcgc29i57qEeiURpm5J4NnEXH9oBYN9Hb74f5NrIcTwPkPtufMgDFR6UmzZPJMl5hw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR05MB1264.eurprd05.prod.outlook.com (2a01:111:e400:5188::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.14; Thu, 7 Jun 2018 12:30:02 +0000 From: Raslan Darawsheh To: thomas@monjalon.net Cc: dev@dpdk.org, rasland@mellanox.com Date: Thu, 7 Jun 2018 15:29:51 +0300 Message-Id: <1528374591-26126-1-git-send-email-rasland@mellanox.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR07CA0176.eurprd07.prod.outlook.com (2603:10a6:802:3e::24) To VI1PR05MB1264.eurprd05.prod.outlook.com (2a01:111:e400:5188::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB1264; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1264; 3:rJKGhsMlQyew5rzgVaxbTYeRGWcKRXjNmfCowkeGnjkgfGBkbnawiOuFwum0u3pvrB8uRJ2pPJsR1Yz06YBgSWXWnK9JiO4jV9biQADr/kYgaxD1omiKt2/uFij5kudikj1kQIbSj+8bCeqVzVIWMehiRvAveHw65enjxBLXYZV/ewoF1YqBH4NljU4EHadiyTw7UOPWe++5GzStJcKdteHXl3gNuh2nwDT6zK1Ny4f39x265aOXEb6LLVoxfc8v; 25:ibEb9TW8L3oSyFSRRqe1v0+40IGFSbBhDQErLIZcH/HaNReVfj/oEXDk1DQjqSzDrc23YDHDwdo0czACpqxElmpheGKhIOOH4bYUNtp8l4TpWr1T1c/QU6x5prV1aFPS+Ekno2BplwQPxle2YjDCuCKRjU8yDDjzDXrSJm7o6YClFsDGVXKPH6h/suhonVMonVmjuDfZJqG9XQWd5S4CKEByyI1AwClEB9Hq4CoS6XYVsVjFU/z3NjMkV6m5bmcyTuWGZwRtGol6HTHqbtc3Bj0bcGzDPnDQjiKmE5VDm2Xj5H7tarsgCA9rhubQlLQ4XATtfEEkClWtFUunAPKh1g==; 31:wrMZ0DdyRNmuQpMql3jmyz5zvmsQ7uCpkqsYjyuDt1MxseEMqrsyg1p8fdpgmvZ/UXGDHjHUhBlR72qog5xVXdT7xojTpIx+tcZccwSrDJpLeT1F5WaNy0oQVENc4BT7+DcNTAd29jwxOjF9DT8MkHhlJ8MCDt7gk/an1aWmqOh52TfodesLNtVN85aqlh8l2cZhz8Rz90F6hphbSat9yDpVFGPPDnjDIAde39zyShA= X-MS-TrafficTypeDiagnostic: VI1PR05MB1264: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1264; 20:4c4YnPnpIrWGFkDAagxSk9pKXLvZ4RAmkDXbwFVPlCr5HvSoEhZKGf25WRFXtqPy+CzjLSgvs/N5cS2QnYb6QWNG8n7jsjRGDVetnLUpaWHN5z+0AtUnUTJ4q+KRHEXiC7nzLRYS1oYN5kg58UWFetO1LoBEgps9BwnJqqMjb2ezT1mTTgN9HkF18w9otddfUBJBjPCfDqFvOXWn7Y3IzE5Tq3teGJtB3aaWpGs4LuzpmV/D2voLwVb+o7cTNqS2xg1618DyR5P7YgBzrCl+kdy1Gy4W4FzraYsKleaZfFqcz61sXKtBEoKqzoR0fO4RBRHX3S6aqb6aPXWlsmQ5JtoNPURF3bJD6JHU2t2gw0v36dYsuQpSjCyeNhmxrqKY7FvuDffCYNgDqbNOA3GDr0JXT1OmEbrOVE941UwDIjTyT0Tgk+nlm+O4FDMm5ZV4RNU4xq/WX2FmHN0JJyUeDEsZzGtmyQwIEuVBBEcwuMJVr+fYJlJ2cTZhu9U9BECS; 4:JqnUmiIL8Yrv2aTgn0W6T9nR8SYiVT3xHYhimGoUYTTQnGldYbxQ5ruwlBdxFGNO1T8qq9Zql9RYXnq24TG7nbPaGhM2ni3OnFZFGR4TJKj8LqMCFRZ/TivNhGJRnrxOxL/POLoHTT0KrgIJI1MDAynlhxHSeRQfDVUFdmQ46i0HatDda0STpo5adfuard3WjIl3w/jhe9t1ffcWRVuOvsyyjtjdIbAobevFgAx+bGYjCRhki4S/upGF6b4houveJPgQK6zHrTk9y1U+x84C2w== 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)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB1264; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB1264; X-Forefront-PRVS: 06968FD8C4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(39380400002)(366004)(396003)(376002)(199004)(189003)(956004)(21086003)(316002)(3846002)(86362001)(47776003)(16586007)(8676002)(26005)(81166006)(81156014)(36756003)(6666003)(6916009)(55016002)(97736004)(66066001)(50466002)(7736002)(305945005)(478600001)(107886003)(186003)(16526019)(50226002)(8936002)(106356001)(105586002)(6116002)(52116002)(51416003)(5890100001)(25786009)(48376002)(7696005)(33026002)(476003)(486006)(5660300001)(386003)(2361001)(2616005)(68736007)(69596002)(59450400001)(2351001)(4326008)(2906002)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB1264; 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; VI1PR05MB1264; 23:crT7yScy3Uq/wn+2hPDP9Xdy6yDijIMPxmXPfC///?= =?us-ascii?Q?4M/EzXXXJzwE7xZa1APOGvr/5rp+2KFSkjPXgnjMLQ/Q3St52Ht8gBUMt/JZ?= =?us-ascii?Q?KwM5V1m5n0KLYhb4xX6qirtd6hcGjwscDYyqU5yk4lzl3i25YnfrvHWomfv2?= =?us-ascii?Q?r7gENAD250g5TB60tfm4zJrjnNLFQWd144n8/x+coxfBNxXXU3AdKiK+QWz5?= =?us-ascii?Q?DuLbSwlc/UB8n/ynhCLFGAAePLnDtBDYu4ynhc9+yc1ML2EB/5Ix4Tn5uVvL?= =?us-ascii?Q?7nYzVkvEVpeV+kyyaKQtKs4+loT0+S+O4qPFVP53BTHX3gdDRRQTGm3JJC/g?= =?us-ascii?Q?eTCOA421ieRDn/TbLX9Q6kedVg7Sf+NtO1V7CH4rPNsncEaVV/dt1Rh2b9sp?= =?us-ascii?Q?14TYX5hIDcQ8wkahwAd8b+1oLEG0QLpacLx1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z09?= X-Microsoft-Antispam-Message-Info: iblMSTivpXor/ke/mhaOb/jpRvzUxyc1ChTzUWt5hU5xqin/gUrY0B9UtvrjxrVizhgNsa1tjG6PpdD43q4hm22lWybAVKAc8AkhCeoobFZNCrgNlB5iy2qZz4ahTd9NeTaYkCfDzTgMPqS38vcHr0YlxoiPo5oPRGBWmaJylxCJ52qM64INMCAUkoXOioDS X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1264; 6:H+lBV5vbkSLZaKoH26pNE5I+awPvIA+taKVK2fwNg+/vv1pNAUPxT25Bs++Tmp899sEwHSANlQ7szFLS85VyId4U7zIFkbHbE4NXQaqg8X1rxMP98Lt1rBTrc06hp0FZt8bEgIwac4dVGIKOn1nse1vDCDlawU7+SatpVnLUSpTgOpDAPBZOS7mfC8sw8Mk2BJbkZRc0VHRLhZZfCsAG9ddRECoWM3AxJ5cPNCpxkbLV6UwJLnuYdmKjbmWI+cb9yax1F71Li4mtAitegfAj7RVdOpiZ0kRE4EmmjYLs44fziGJKmhMJmerRdTBLrce2DBNWAfBexoyWfNsT3HVK9FgzzZTtrhjZGXZuYT7V3cByXpU0+GwVggIIoeixqB27kygYLHcN8VbE4SGEqrOjNxXcUhNxW+snVQc7JNF/WqGr0iVBbzbNKxUx+C9h9va18Hncy0AEb/TNlbFpKAlMWw==; 5:CRwYXwtLRN7+Yg6AWLkLCkupXgfc4Kz5CvC9EIOmqK4wsW8uUe4muPKsEFfBzXp+bfCeRgBb9CMRlT5bu1zjGX3nLv9whg8xgV/ogVyGBjjusFIzdISn4zyThYvBLZBePN0yRretU3ojlInyf+ZMTX74Q0Ri7Ehd1ivh87jKRjo=; 24:gevRbk2vjM77TLrbCDP5BC6F8o6eNkdQsA/3J+SxWc/awD8iGNDbvd/UuKUgT9IP5YXF0hXOYxKmnnD1jx+s1IBXafeDNqj8WzG435CKbsA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB1264; 7:bUxzh6K+WIsBOIqiTKDnA/6yVt+/sXGwT+p6cdKRtRZhmlwi58KmGsrA9LPV+gTIdtvgSEC3wpMznaUABNDBlqsBGFK+N2PgDRz/PZNAt0ekQ39F8LGAXSpxb4pVzpXuUMA0bEAzbO0wG7qsMyXAMK8dsnu2/ISTFkjKHd5w38g5YdF1Dlrk4iw8DkoMj2V+naWhWQupG2L9NNZZyDT/wnMOi9PEQ5NgNvck2qh8tLm5KqGSdkH0i3+zgRDJnCJ9 X-MS-Office365-Filtering-Correlation-Id: e3786c72-d184-423c-7081-08d5cc7264a5 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2018 12:30:02.4381 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3786c72-d184-423c-7081-08d5cc7264a5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1264 Subject: [dpdk-dev] [RFC] net/tap: add queues when attaching from secondary process 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: Thu, 07 Jun 2018 12:30:04 -0000 In the case where the device is created by the primary process. Currently, secondary process only contains the eth dev without being able to do any Rx/Tx. When attaching the device from secondary process this patch adds queues info got from IPC massaging. Signed-off-by: Raslan Darawsheh --- drivers/net/tap/Makefile | 2 + drivers/net/tap/rte_eth_tap.c | 105 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/drivers/net/tap/Makefile b/drivers/net/tap/Makefile index ccc5c5f..913423c 100644 --- a/drivers/net/tap/Makefile +++ b/drivers/net/tap/Makefile @@ -27,6 +27,8 @@ LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_hash LDLIBS += -lrte_bus_vdev CFLAGS += -DTAP_MAX_QUEUES=$(TAP_MAX_QUEUES) +CFLAGS += -DALLOW_EXPERIMENTAL_API + # # all source are stored in SRCS-y diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 5531fe9..0f4c8d9 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include @@ -55,6 +57,9 @@ #define ETH_TAP_CMP_MAC_FMT "0123456789ABCDEFabcdef" #define ETH_TAP_MAC_ARG_FMT ETH_TAP_MAC_FIXED "|" ETH_TAP_USR_MAC_FMT +/* IPC key for communication of queue fds between processes. */ +#define TAP_MP_KEY "tap_mp_exchange_fds" + static struct rte_vdev_driver pmd_tap_drv; static struct rte_vdev_driver pmd_tun_drv; @@ -93,6 +98,15 @@ enum ioctl_mode { REMOTE_ONLY, }; +/* To communicate queue infos between processes */ +struct queues_fds { + char name[RTE_DEV_NAME_MAX_LEN]; + int num_rxq_fds; + int num_txq_fds; + int rxq_fds[RTE_PMD_TAP_MAX_QUEUES]; + int txq_fds[RTE_PMD_TAP_MAX_QUEUES]; +}; + static int tap_intr_handle_set(struct rte_eth_dev *dev, int set); /** @@ -1731,6 +1745,47 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev) return ret; } +/* + * Send the queues fds from the primary process to secondary. + */ +static int +tap_exchange_queues_fds(const struct rte_mp_msg *mp_msg, const void *peer) +{ + struct rte_eth_dev *eth_dev; + struct rte_mp_msg mp_resp; + struct queues_fds *out = (struct queues_fds *)&mp_resp.param; + const struct queues_fds *in = (const struct queues_fds *)mp_msg->param; + uint16_t port_id; + int i, ret; + + TAP_LOG(DEBUG, "received request"); + strlcpy(out->name, in->name, sizeof(out->name)); + ret = rte_eth_dev_get_port_by_name(in->name, &port_id); + if (ret) { + TAP_LOG(ERR, "Failed to get dev %s", in->name); + return -1; + } + eth_dev = &rte_eth_devices[port_id]; + struct pmd_internals *pmd = eth_dev->data->dev_private; + + /* fill the queues fds data in the reply msg */ + strlcpy(mp_resp.name, TAP_MP_KEY, sizeof(mp_resp.name)); + out->num_rxq_fds = eth_dev->data->nb_rx_queues; + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) + out->rxq_fds[i] = pmd->rxq[i].fd; + out->num_txq_fds = eth_dev->data->nb_tx_queues; + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) + out->txq_fds[i] = pmd->txq[i].fd; + mp_resp.len_param = sizeof(*out); + mp_resp.num_fds = 0; + if (rte_mp_reply(&mp_resp, peer) < 0) { + TAP_LOG(ERR, "Failed to reply a fds request"); + return -1; + } + + return 0; +} + /* Open a TAP interface device. */ static int @@ -1744,6 +1799,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) char remote_iface[RTE_ETH_NAME_MAX_LEN]; struct ether_addr user_mac = { .addr_bytes = {0} }; struct rte_eth_dev *eth_dev; + int queue_id; strcpy(tuntap_name, "TAP"); @@ -1757,8 +1813,46 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) TAP_LOG(ERR, "Failed to probe %s", name); return -1; } - /* TODO: request info from primary to set up Rx and Tx */ eth_dev->dev_ops = &ops; + /* request a sync from the primary process to get queues fds */ + eth_dev->rx_pkt_burst = pmd_rx_burst; + eth_dev->tx_pkt_burst = pmd_tx_burst; + if (!rte_eal_primary_proc_alive(NULL)) { + TAP_LOG(ERR, "cannot initialize secondary process " + "without a primary one"); + return -1; + } + struct rte_mp_msg mp_req, *mp_rep; + struct rte_mp_reply mp_reply; + struct timespec ts = {.tv_sec = 5, .tv_nsec = 0}; + struct queues_fds *req = (struct queues_fds *)mp_req.param; + struct queues_fds *resp; + + strlcpy(req->name, name, sizeof(mp_req.name)); + strlcpy(mp_req.name, TAP_MP_KEY, sizeof(mp_req.name)); + mp_req.len_param = sizeof(*req); + /* request for sync from primary process to get queues fds. */ + if (rte_mp_request_sync(&mp_req, &mp_reply, &ts) == 0 && + mp_reply.nb_received == 1) { + mp_rep = &mp_reply.msgs[0]; + resp = (struct queues_fds *)mp_rep->param; + TAP_LOG(INFO, "Received fds for %d rx_queues and " + "%d tx_queues", resp->num_rxq_fds, + resp->num_txq_fds); + } else { + TAP_LOG(ERR, "Failed to request queues from primary"); + return -1; + } + + struct pmd_internals *pmd = eth_dev->data->dev_private; + for (queue_id = 0; queue_id < resp->num_rxq_fds; queue_id++) + pmd->rxq[queue_id].fd = resp->rxq_fds[queue_id]; + + for (queue_id = 0; queue_id < resp->num_txq_fds; queue_id++) + pmd->txq[queue_id].fd = resp->txq_fds[queue_id]; + + TAP_LOG(NOTICE, "Initializing secondary process pmd_tap for %s", + name); rte_eth_dev_probing_finish(eth_dev); return 0; } @@ -1806,6 +1900,14 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) TAP_LOG(NOTICE, "Initializing pmd_tap for %s as %s", name, tap_name); + /* register for mp communication between secondary and primary */ + if (rte_mp_action_register(TAP_MP_KEY, tap_exchange_queues_fds) && + rte_errno != EEXIST) { + TAP_LOG(ERR, "%s : %s fail to register MP action : %s", + tuntap_name, name, strerror(errno)); + return -1; + } + ret = eth_dev_tap_create(dev, tap_name, remote_iface, &user_mac, ETH_TUNTAP_TYPE_TAP); @@ -1813,6 +1915,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) if (ret == -1) { TAP_LOG(ERR, "Failed to create pmd for %s as %s", name, tap_name); + rte_mp_action_unregister(TAP_MP_KEY); tap_unit--; /* Restore the unit number */ } rte_kvargs_free(kvlist); -- 2.7.4