[dpdk-dev] [PATCH v2] net/memif: multi-process support

Burakov, Anatoly anatoly.burakov at intel.com
Tue Jun 18 11:20:28 CEST 2019


On 18-Jun-19 9:48 AM, Jakub Grajciar wrote:
> Multi-process support for memif PMD.
> Primary process handles connection establishment.
> Secondary process queries for memory regions.
> 
> Signed-off-by: Jakub Grajciar <jgrajcia at cisco.com>
> ---

<...>

> +/*
> + * Request regions
> + * Called by secondary process, when ports link status goes up.
> + */
> +static int
> +memif_mp_request_regions(struct rte_eth_dev *dev)
> +{
> +	int ret, i;
> +	struct timespec timeout = {.tv_sec = 5, .tv_nsec = 0};
> +	struct rte_mp_msg msg, *reply;
> +	struct rte_mp_reply replies;
> +	struct mp_region_msg *msg_param = (struct mp_region_msg *)msg.param;
> +	struct mp_region_msg *reply_param;
> +	struct memif_region *r;
> +	struct pmd_process_private *proc_private = dev->process_private;
> +
> +	MIF_LOG(DEBUG, "Requesting memory regions");
> +
> +	for (i = 0; i < ETH_MEMIF_MAX_REGION_NUM; i++) {
> +		/* Prepare the message */
> +		memset(&msg, 0, sizeof(msg));
> +		strlcpy(msg.name, MEMIF_MP_SEND_REGION, sizeof(msg.name));
> +		strlcpy(msg_param->port_name, dev->data->name,
> +			sizeof(msg_param->port_name));
> +		msg_param->idx = i;
> +		msg.len_param = sizeof(*msg_param);
> +
> +		/* Send message */
> +		ret = rte_mp_request_sync(&msg, &replies, &timeout);
> +		if (ret < 0 || replies.nb_received != 1) {
> +			MIF_LOG(ERR, "Failed to send mp msg: %d",
> +				rte_errno);
> +			return -1;
> +		}
> +
> +		reply = &replies.msgs[0];
> +		reply_param = (struct mp_region_msg *)reply->param;
> +
> +		if (reply_param->size > 0) {
> +			r = rte_zmalloc("region", sizeof(struct memif_region), 0);
> +			if (r == NULL) {
> +				MIF_LOG(ERR, "Failed to alloc memif region.");
> +                                free(reply);
> +                                return -ENOMEM;
> +			}
> +			r->region_size = reply_param->size;
> +			if (reply->num_fds < 1) {
> +				MIF_LOG(ERR, "Missing file descriptor.");
> +                                free(reply);
> +                                return -1;
> +			}
> +			r->fd = reply->fds[0];
> +			r->addr = NULL;
> +
> +			proc_private->regions[reply_param->idx] = r;
> +			proc_private->regions_num++;
> +		}
> +	}
> +
> +        free(reply);

Indentation here is wrong, but more importantly, you're sending requests 
in a loop, but you're only freeing the last reply. This should be inside 
the loop, not outside it.


-- 
Thanks,
Anatoly


More information about the dev mailing list