DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Raslan Darawsheh <rasland@mellanox.com>,
	"keith.wiles@intel.com" <keith.wiles@intel.com>
Cc: Thomas Monjalon <thomas@monjalon.net>,
	"dev@dpdk.org" <dev@dpdk.org>,
	Shahaf Shuler <shahafs@mellanox.com>,
	Ori Kam <orika@mellanox.com>
Subject: Re: [dpdk-dev] [PATCH v4 2/2] net/tap: add queues when attaching from secondary process
Date: Wed, 3 Oct 2018 19:00:14 +0100	[thread overview]
Message-ID: <a814e0e8-d1ea-22f4-b58d-277dd8b73124@intel.com> (raw)
In-Reply-To: <1538476438-20891-2-git-send-email-rasland@mellanox.com>

On 10/2/2018 11:34 AM, Raslan Darawsheh wrote:
> In the case the device is created by the primary process,
> the secondary must request some file descriptors to attach the queues.
> The file descriptors are shared via IPC Unix socket.
> 
> Thanks to the IPC synchronization, the secondary process
> is now able to do Rx/Tx on a TAP created by the primary process.
> 
> Signed-off-by: Raslan Darawsheh <rasland@mellanox.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
<...>

> +/* Request queue file descriptors from secondary to primary. */
> +static int
> +tap_mp_attach_queues(const char *port_name, struct rte_eth_dev *dev)
> +{
> +	int ret;
> +	struct timespec timeout = {.tv_sec = 1, .tv_nsec = 0};
> +	struct rte_mp_msg request, *reply;
> +	struct rte_mp_reply replies;
> +	struct ipc_queues *request_param = (struct ipc_queues *)request.param;
> +	struct ipc_queues *reply_param;
> +	int queue, fd_iterator;
> +
> +	/* Prepare the request */
> +	strlcpy(request.name, TAP_MP_KEY, sizeof(request.name));
> +	strlcpy(request_param->port_name, port_name,
> +		sizeof(request_param->port_name));
> +	request.len_param = sizeof(*request_param);
> +	/* Send request and receive reply */
> +	ret = rte_mp_request_sync(&request, &replies, &timeout);
> +	if (ret < 0) {
> +		TAP_LOG(ERR, "Failed to request queues from primary: %d",
> +			rte_errno);
> +		return -1;
> +	}
> +	reply = &replies.msgs[0];
> +	reply_param = (struct ipc_queues *)reply->param;
> +	TAP_LOG(DEBUG, "Received IPC reply for %s", reply_param->port_name);
> +
> +	/* Attach the queues from received file descriptors */
> +
> +	dev->data->nb_rx_queues = reply_param->rxq_count;
> +	dev->data->nb_tx_queues = reply_param->txq_count;
> +	fd_iterator = 0;
> +	for (queue = 0; queue < reply_param->rxq_count; queue++)
> +		process_private->rxq_fds[queue] = reply->fds[fd_iterator++];
> +	for (queue = 0; queue < reply_param->txq_count; queue++)
> +		process_private->txq_fds[queue] = reply->fds[fd_iterator++];

Based on comment in prev patch,
"process_private" is the address of the memory block for last eth_dev probed, we
need this something linked to dev, like "dev->data->nb_rx_queues".
But this will be work fine because it is called just after memory allocated,
please check below one.

Also the problem here is, this is secondary process and nobody sets
dev->data->rxq[i].fd to point process_private? So you have correct fds on
"process_private" but your redirection doesn't point here.
(Please remember redirection set in eth_dev_tap_create() which called only for
primary.)

> +
> +	return 0;
> +}
> +
> +/* Send the queue file descriptors from the primary process to secondary. */
> +static int
> +tap_mp_sync_queues(const struct rte_mp_msg *request, const void *peer)
> +{
> +	struct rte_eth_dev *dev;
> +	struct rte_mp_msg reply;
> +	const struct ipc_queues *request_param =
> +		(const struct ipc_queues *)request->param;
> +	struct ipc_queues *reply_param =
> +		(struct ipc_queues *)reply.param;
> +	uint16_t port_id;
> +	int queue;
> +	int ret;
> +
> +	/* Get requested port */
> +	TAP_LOG(DEBUG, "Received IPC request for %s", request_param->port_name);
> +	ret = rte_eth_dev_get_port_by_name(request_param->port_name, &port_id);
> +	if (ret) {
> +		TAP_LOG(ERR, "Failed to get port id for %s",
> +			request_param->port_name);
> +		return -1;
> +	}
> +	dev = &rte_eth_devices[port_id];
> +
> +	/* Fill file descriptors for all queues */
> +	reply.num_fds = 0;
> +	reply_param->rxq_count = 0;
> +	for (queue = 0; queue < dev->data->nb_rx_queues; queue++) {
> +		reply.fds[reply.num_fds++] = process_private->rxq_fds[queue];

This is "process_private" in primary. If you have multiple tap device this point
the memory block for last one.
When secondary asks for fds for a device "dev", you are always sending the last
ones, which is wrong.
This can work if you have only one tap device but not if you have more.


Briefly there are two problems with this patch:
1- "process_private" should be per eth_dev instead of globally for tap
2- Need a non shared memory location to save fds (or pointers to fds),
redirection is not helping here.

  parent reply	other threads:[~2018-10-03 18:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 12:29 [dpdk-dev] [RFC] " Raslan Darawsheh
2018-06-07 19:09 ` Wiles, Keith
2018-06-07 23:24   ` Raslan Darawsheh
2018-06-08  2:52     ` Wiles, Keith
2018-06-12 12:46     ` Wiles, Keith
2018-06-12 13:21       ` Raslan Darawsheh
2018-07-20 10:57 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
2018-09-27 11:19   ` [dpdk-dev] [PATCH v3 1/2] net/tap: change queue fd to be pointers to process private Raslan Darawsheh
2018-09-27 11:19     ` [dpdk-dev] [PATCH v3 2/2] net/tap: add queues when attaching from secondary process Raslan Darawsheh
2018-09-27 13:04       ` Wiles, Keith
2018-09-27 18:53         ` Thomas Monjalon
2018-10-02 10:34       ` [dpdk-dev] [PATCH v4 1/2] net/tap: change queue fd to be pointers to process private Raslan Darawsheh
2018-10-02 10:34         ` [dpdk-dev] [PATCH v4 2/2] net/tap: add queues when attaching from secondary process Raslan Darawsheh
2018-10-02 10:41           ` Thomas Monjalon
2018-10-02 10:50             ` Raslan Darawsheh
2018-10-02 11:38               ` Thomas Monjalon
2018-10-03 16:28                 ` Ferruh Yigit
2018-10-02 10:43           ` Thomas Monjalon
2018-10-03 16:31             ` Ferruh Yigit
2018-10-03 18:00           ` Ferruh Yigit [this message]
2018-10-03 17:59         ` [dpdk-dev] [PATCH v4 1/2] net/tap: change queue fd to be pointers to process private Ferruh Yigit
2018-09-27 13:17     ` [dpdk-dev] [PATCH v3 " Wiles, Keith
2018-10-02 10:30       ` Raslan Darawsheh
2018-10-02 12:58         ` Wiles, Keith
2018-10-03 17:27           ` Ferruh Yigit
2018-07-20 11:15 ` [dpdk-dev] [PATCH v3] net/tap: add queues when attaching from secondary process Thomas Monjalon
2018-07-20 15:35   ` Wiles, Keith
2018-07-20 21:51     ` Thomas Monjalon
2018-07-21 13:44       ` Wiles, Keith
2018-08-23 11:51   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a814e0e8-d1ea-22f4-b58d-277dd8b73124@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=keith.wiles@intel.com \
    --cc=orika@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).