From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id C5BAE1B2D4 for ; Sun, 5 Nov 2017 11:15:11 +0100 (CET) Received: by mail-wm0-f67.google.com with SMTP id p75so8569783wmg.3 for ; Sun, 05 Nov 2017 02:15:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=4OJK4++VlfQVYTQe1YSTRZ98nj3B9PlxQrpwBXnEtn8=; b=CWvj4CvSC07cDe6zkOD6tTnQN75MgA8c7X1T9GiZKKgrLAXpgzxf5BR1abIFHwALCM RtqXO2B0Vf43bhbhT8UHWrs4sIt2W9C8HnszPyUN5vp7z4FZ9L01cwky/Nzg2xJL1jS1 BZ0c3wmPJifriq5jS9DSTVRHEFWGoXBkOvskOK7p9I8HBq+A0GneRsvk5XMQ3mzrfKLB xFATpawMdV5MD4u3AkDTGGZf4x07vC6jKDPHoExyBT4VKr9OKgdx+pJqpKk+jzqGEav8 mUQrDs1ARJFMl4/+IC0K/a1ogv4tBD7oEuf4FjaqdctCdpVW7c+P6nsMdvbu1Vje8AkI N4+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=4OJK4++VlfQVYTQe1YSTRZ98nj3B9PlxQrpwBXnEtn8=; b=F2GMR+6MCOIon/t6h0adGgH5GH2v5dk8ctENxocI539o6L6hPOojI1YtrsCOK8agaF Alqd4tD/qBPZr/u+KaePPlb1USRkqesAUwD6Rb//dV0f0vMY5Vu85Xpms7edLIF5mc2j kA7h8ehqqkfZ19Zv3Nq2+6IP3Mj+gfT6hJ1VW3tpSQF5Ww+pBFn/3RFPw6uaZcPjJW0+ gxJPdh1RLRMrpltizpwrFKDN8V1awcYoEbO5PM8EST7j0K1BWOXl/l4MuBW2vfOTBM+P eBvRrXNVo/smJHkImUqi7d8GW0mbqurKr0Sk52sNUH7ocK+ikIA64BrR83NsGHDVtoNU r5LA== X-Gm-Message-State: AMCzsaUNXcHFEAdUt9OzEbZAHWUHP7zS4KzEUGNvreNya2R0AurM8Bun ucronf0m7AAE2cUG2YWRooao2zvT X-Google-Smtp-Source: ABhQp+SkiXEd0gqFBG87XVKmxPiam8mIsPHiNDMob71KM0QOzFAu05Fhw+XxUwIlhghaBUgNjUwc3w== X-Received: by 10.80.181.71 with SMTP id z7mr15924391edd.201.1509876911158; Sun, 05 Nov 2017 02:15:11 -0800 (PST) Received: from [10.0.1.160] ([78.129.189.119]) by smtp.gmail.com with ESMTPSA id w7sm9361526edw.65.2017.11.05.02.15.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Nov 2017 02:15:10 -0800 (PST) From: Ilya Matveychikov Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Date: Sun, 5 Nov 2017 14:15:09 +0400 References: To: dev@dpdk.org In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3273) Subject: [dpdk-dev] net/pcap: remove single interface constraint (v2) 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: Sun, 05 Nov 2017 10:15:11 -0000 Hello folks, This patch removes single interface constraint from the libpcap-based = PMD. The problem it solves is to allow PCAP device consists of more than = single device: # testpmd --vdev net_pcap0,iface=3DvethA,iface=3DvethB,iface=3DvethC = and so.. I found the issue when performed RSS emulation based on PCAP PMD. For my task I had to create multi-queue PCAP device based on a number of veth devices which in turn was combined in bonding device. Signed-off-by: Ilya V. Matveychikov --- drivers/net/pcap/rte_eth_pcap.c | 77 = +++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c = b/drivers/net/pcap/rte_eth_pcap.c index defb3b4..ae03c3b 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -94,7 +94,6 @@ struct pmd_internals { struct pcap_rx_queue rx_queue[RTE_PMD_PCAP_MAX_QUEUES]; struct pcap_tx_queue tx_queue[RTE_PMD_PCAP_MAX_QUEUES]; int if_index; - int single_iface; }; struct pmd_devargs { @@ -441,15 +440,19 @@ eth_dev_start(struct rte_eth_dev *dev) struct pcap_rx_queue *rx; /* Special iface case. Single pcap is open and shared between = tx/rx. */ - if (internals->single_iface) { - tx =3D &internals->tx_queue[0]; - rx =3D &internals->rx_queue[0]; - - if (!tx->pcap && strcmp(tx->type, ETH_PCAP_IFACE_ARG) =3D=3D= 0) { - if (open_single_iface(tx->name, &tx->pcap) < 0) - return -1; - rx->pcap =3D tx->pcap; + if (internals->tx_queue[0].pcap =3D=3D = internals->rx_queue[0].pcap) { + RTE_ASSERT(dev->data->nb_tx_queues =3D=3D = dev->data->nb_rx_queues); + for (i =3D 0; i < dev->data->nb_tx_queues; i++) { + tx =3D &internals->tx_queue[i]; + rx =3D &internals->rx_queue[i]; + + if (!tx->pcap && strcmp(tx->type, = ETH_PCAP_IFACE_ARG) =3D=3D 0) { + if (open_single_iface(tx->name, = &tx->pcap) < 0) + return -1; + rx->pcap =3D tx->pcap; + } } + goto status_up; } @@ -504,12 +507,15 @@ eth_dev_stop(struct rte_eth_dev *dev) struct pcap_rx_queue *rx; /* Special iface case. Single pcap is open and shared between = tx/rx. */ - if (internals->single_iface) { - tx =3D &internals->tx_queue[0]; - rx =3D &internals->rx_queue[0]; - pcap_close(tx->pcap); - tx->pcap =3D NULL; - rx->pcap =3D NULL; + if (internals->tx_queue[0].pcap =3D=3D = internals->rx_queue[0].pcap) { + RTE_ASSERT(dev->data->nb_tx_queues =3D=3D = dev->data->nb_rx_queues); + for (i =3D 0; i < dev->data->nb_tx_queues; i++) { + tx =3D &internals->tx_queue[i]; + rx =3D &internals->rx_queue[i]; + pcap_close(tx->pcap); + tx->pcap =3D NULL; + rx->pcap =3D NULL; + } goto status_down; } @@ -730,6 +736,7 @@ open_tx_pcap(const char *key, const char *value, = void *extra_args) static inline int open_rx_tx_iface(const char *key, const char *value, void *extra_args) { + unsigned int i; const char *iface =3D value; struct pmd_devargs *tx =3D extra_args; pcap_t *pcap =3D NULL; @@ -737,9 +744,14 @@ open_rx_tx_iface(const char *key, const char = *value, void *extra_args) if (open_single_iface(iface, &pcap) < 0) return -1; - tx->queue[0].pcap =3D pcap; - tx->queue[0].name =3D iface; - tx->queue[0].type =3D key; + for (i =3D 0; i < tx->num_of_queue; i++) { + if (tx->queue[i].pcap =3D=3D NULL) { + tx->queue[i].pcap =3D pcap; + tx->queue[i].name =3D iface; + tx->queue[i].type =3D key; + break; + } + } return 0; } @@ -901,8 +913,7 @@ static int eth_from_pcaps(struct rte_vdev_device *vdev, struct pmd_devargs *rx_queues, const unsigned int = nb_rx_queues, struct pmd_devargs *tx_queues, const unsigned int = nb_tx_queues, - struct rte_kvargs *kvlist, int single_iface, - unsigned int using_dumpers) + struct rte_kvargs *kvlist, unsigned int using_dumpers) { struct pmd_internals *internals =3D NULL; struct rte_eth_dev *eth_dev =3D NULL; @@ -914,9 +925,6 @@ eth_from_pcaps(struct rte_vdev_device *vdev, if (ret < 0) return ret; - /* store weather we are using a single interface for rx/tx or = not */ - internals->single_iface =3D single_iface; - eth_dev->rx_pkt_burst =3D eth_pcap_rx; if (using_dumpers) @@ -935,7 +943,6 @@ pmd_pcap_probe(struct rte_vdev_device *dev) struct rte_kvargs *kvlist; struct pmd_devargs pcaps =3D {0}; struct pmd_devargs dumpers =3D {0}; - int single_iface =3D 0; int ret; name =3D rte_vdev_device_name(dev); @@ -953,19 +960,21 @@ pmd_pcap_probe(struct rte_vdev_device *dev) * If iface argument is passed we open the NICs and use them for * reading / writing */ - if (rte_kvargs_count(kvlist, ETH_PCAP_IFACE_ARG) =3D=3D 1) { + if (rte_kvargs_count(kvlist, ETH_PCAP_IFACE_ARG)) { + int i, queues =3D rte_kvargs_count(kvlist, = ETH_PCAP_IFACE_ARG); - ret =3D rte_kvargs_process(kvlist, ETH_PCAP_IFACE_ARG, - &open_rx_tx_iface, &pcaps); + pcaps.num_of_queue =3D queues; + dumpers.num_of_queue =3D queues; - if (ret < 0) - goto free_kvlist; + for (i =3D 0; i < queues; i++) { + ret =3D rte_kvargs_process(kvlist, = ETH_PCAP_IFACE_ARG, + &open_rx_tx_iface, = &pcaps); - dumpers.queue[0] =3D pcaps.queue[0]; + if (ret < 0) + goto free_kvlist; - single_iface =3D 1; - pcaps.num_of_queue =3D 1; - dumpers.num_of_queue =3D 1; + dumpers.queue[i] =3D pcaps.queue[i]; + } goto create_eth; } @@ -1020,7 +1029,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev) create_eth: ret =3D eth_from_pcaps(dev, &pcaps, pcaps.num_of_queue, = &dumpers, - dumpers.num_of_queue, kvlist, single_iface, is_tx_pcap); + dumpers.num_of_queue, kvlist, is_tx_pcap); free_kvlist: rte_kvargs_free(kvlist); -- 2.7.4=