From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id ADBEFF985 for ; Thu, 7 Jun 2018 21:09:52 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 12:09:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,487,1520924400"; d="scan'208";a="206213619" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga004.jf.intel.com with ESMTP; 07 Jun 2018 12:09:51 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 7 Jun 2018 12:09:50 -0700 Received: from fmsmsx117.amr.corp.intel.com ([169.254.3.220]) by fmsmsx115.amr.corp.intel.com ([169.254.4.60]) with mapi id 14.03.0319.002; Thu, 7 Jun 2018 12:09:50 -0700 From: "Wiles, Keith" To: Raslan Darawsheh CC: "thomas@monjalon.net" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC] net/tap: add queues when attaching from secondary process Thread-Index: AQHT/ltc2p14uFzXIUGxKYM283mZUqRVntkA Date: Thu, 7 Jun 2018 19:09:50 +0000 Message-ID: <077BA557-4ED0-4BAF-AFD7-8F54116229DB@intel.com> References: <1528374591-26126-1-git-send-email-rasland@mellanox.com> In-Reply-To: <1528374591-26126-1-git-send-email-rasland@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.252.143.59] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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 19:09:53 -0000 > On Jun 7, 2018, at 5:29 AM, Raslan Darawsheh wrote= : >=20 > 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. >=20 > When attaching the device from secondary process this patch adds queues > info got from IPC massaging. Can you explain this details a bit more here, not sure I follow the real pr= oblem and the solution? >=20 > 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(-) >=20 > 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 +=3D -lrte_ethdev -lrte_net -lrte_kvargs -lrte_h= ash > LDLIBS +=3D -lrte_bus_vdev >=20 > CFLAGS +=3D -DTAP_MAX_QUEUES=3D$(TAP_MAX_QUEUES) > +CFLAGS +=3D -DALLOW_EXPERIMENTAL_API > + >=20 > # > # 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 >=20 > #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 >=20 > +/* 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; >=20 > @@ -93,6 +98,15 @@ enum ioctl_mode { > REMOTE_ONLY, > }; >=20 > +/* 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); >=20 > /** > @@ -1731,6 +1745,47 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev) > return ret; > } >=20 > +/* > + * 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 *pee= r) > +{ > + struct rte_eth_dev *eth_dev; > + struct rte_mp_msg mp_resp; > + struct queues_fds *out =3D (struct queues_fds *)&mp_resp.param; > + const struct queues_fds *in =3D (const struct queues_fds *)mp_msg->para= m; > + uint16_t port_id; > + int i, ret; > + > + TAP_LOG(DEBUG, "received request"); > + strlcpy(out->name, in->name, sizeof(out->name)); > + ret =3D 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 =3D &rte_eth_devices[port_id]; > + struct pmd_internals *pmd =3D 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 =3D eth_dev->data->nb_rx_queues; > + for (i =3D 0; i < eth_dev->data->nb_rx_queues; i++) > + out->rxq_fds[i] =3D pmd->rxq[i].fd; > + out->num_txq_fds =3D eth_dev->data->nb_tx_queues; > + for (i =3D 0; i < eth_dev->data->nb_tx_queues; i++) > + out->txq_fds[i] =3D pmd->txq[i].fd; > + mp_resp.len_param =3D sizeof(*out); > + mp_resp.num_fds =3D 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 =3D { .addr_bytes =3D {0} }; > struct rte_eth_dev *eth_dev; > + int queue_id; >=20 > strcpy(tuntap_name, "TAP"); >=20 > @@ -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 =3D &ops; > + /* request a sync from the primary process to get queues fds */ > + eth_dev->rx_pkt_burst =3D pmd_rx_burst; > + eth_dev->tx_pkt_burst =3D 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 =3D {.tv_sec =3D 5, .tv_nsec =3D 0}; > + struct queues_fds *req =3D (struct queues_fds *)mp_req.param; > + struct queues_fds *resp; What is the rule for DPDK coding style of having declares in the middle of = a block, I thought we only wanted them at the beginning of block of code. > + > + strlcpy(req->name, name, sizeof(mp_req.name)); > + strlcpy(mp_req.name, TAP_MP_KEY, sizeof(mp_req.name)); > + mp_req.len_param =3D sizeof(*req); > + /* request for sync from primary process to get queues fds. */ > + if (rte_mp_request_sync(&mp_req, &mp_reply, &ts) =3D=3D 0 && > + mp_reply.nb_received =3D=3D 1) { > + mp_rep =3D &mp_reply.msgs[0]; > + resp =3D (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; > + } I thought passing a FD from process to process you had to have the kernel c= onvert the FD to the local process value. At least that was the way it was = done in mmap memory FD. Is this the same problem and needs to be send in a = message using a control structure with the correct flags set? > + > + struct pmd_internals *pmd =3D eth_dev->data->dev_private; > + for (queue_id =3D 0; queue_id < resp->num_rxq_fds; queue_id++) > + pmd->rxq[queue_id].fd =3D resp->rxq_fds[queue_id]; > + > + for (queue_id =3D 0; queue_id < resp->num_txq_fds; queue_id++) > + pmd->txq[queue_id].fd =3D 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); >=20 > + /* register for mp communication between secondary and primary */ > + if (rte_mp_action_register(TAP_MP_KEY, tap_exchange_queues_fds) && > + rte_errno !=3D EEXIST) { > + TAP_LOG(ERR, "%s : %s fail to register MP action : %s", > + tuntap_name, name, strerror(errno)); > + return -1; > + } > + > ret =3D eth_dev_tap_create(dev, tap_name, remote_iface, &user_mac, > ETH_TUNTAP_TYPE_TAP); >=20 > @@ -1813,6 +1915,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) > if (ret =3D=3D -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); > --=20 > 2.7.4 >=20 Regards, Keith