[v2] net/kni: set packet input port in Rx

Message ID 20200724151028.1297434-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/kni: set packet input port in Rx |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Ferruh Yigit July 24, 2020, 3:10 p.m. UTC
  From: jiancheng pei <jpei@sonicwall.com>

Store port_id in pmd_internals when eth kni device is created.
Then set packet port of rte_mbuf in function eth_kni_rx.

Signed-off-by: Jecky Pei <jpei@sonicwall.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/kni/rte_eth_kni.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

David Marchand July 29, 2020, 5:02 p.m. UTC | #1
On Fri, Jul 24, 2020 at 5:10 PM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>
> From: jiancheng pei <jpei@sonicwall.com>
>
> Store port_id in pmd_internals when eth kni device is created.
> Then set packet port of rte_mbuf in function eth_kni_rx.

LGTM.

Is this fix worth a backport?
A net driver is expected to set the port in all mbufs (m->port is
initialised/reset to MBUF_INVALID_PORT).


>
> Signed-off-by: Jecky Pei <jpei@sonicwall.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>  drivers/net/kni/rte_eth_kni.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
> index cde98f0bb2..831fe96c96 100644
> --- a/drivers/net/kni/rte_eth_kni.c
> +++ b/drivers/net/kni/rte_eth_kni.c
> @@ -47,6 +47,7 @@ struct pmd_queue {
>
>  struct pmd_internals {
>         struct rte_kni *kni;
> +       uint16_t port_id;
>         int is_kni_started;
>
>         pthread_t thread;
> @@ -78,8 +79,11 @@ eth_kni_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
>         struct pmd_queue *kni_q = q;
>         struct rte_kni *kni = kni_q->internals->kni;
>         uint16_t nb_pkts;
> +       int i;
>
>         nb_pkts = rte_kni_rx_burst(kni, bufs, nb_bufs);
> +       for (i = 0; i < nb_pkts; i++)
> +               bufs[i]->port = kni_q->internals->port_id;
>
>         kni_q->rx.pkts += nb_pkts;
>
> @@ -372,6 +376,7 @@ eth_kni_create(struct rte_vdev_device *vdev,
>                 return NULL;
>
>         internals = eth_dev->data->dev_private;
> +       internals->port_id = eth_dev->data->port_id;
>         data = eth_dev->data;
>         data->nb_rx_queues = 1;
>         data->nb_tx_queues = 1;
> --
> 2.25.4
>
  
Ferruh Yigit July 29, 2020, 5:06 p.m. UTC | #2
On 7/29/2020 6:02 PM, David Marchand wrote:
> On Fri, Jul 24, 2020 at 5:10 PM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>>
>> From: jiancheng pei <jpei@sonicwall.com>
>>
>> Store port_id in pmd_internals when eth kni device is created.
>> Then set packet port of rte_mbuf in function eth_kni_rx.
> 
> LGTM.
> 
> Is this fix worth a backport?

Makes sense, +1 to add stable tag.

> A net driver is expected to set the port in all mbufs (m->port is
> initialised/reset to MBUF_INVALID_PORT).
> 
> 
>>
>> Signed-off-by: Jecky Pei <jpei@sonicwall.com>
>> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>>  drivers/net/kni/rte_eth_kni.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
>> index cde98f0bb2..831fe96c96 100644
>> --- a/drivers/net/kni/rte_eth_kni.c
>> +++ b/drivers/net/kni/rte_eth_kni.c
>> @@ -47,6 +47,7 @@ struct pmd_queue {
>>
>>  struct pmd_internals {
>>         struct rte_kni *kni;
>> +       uint16_t port_id;
>>         int is_kni_started;
>>
>>         pthread_t thread;
>> @@ -78,8 +79,11 @@ eth_kni_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
>>         struct pmd_queue *kni_q = q;
>>         struct rte_kni *kni = kni_q->internals->kni;
>>         uint16_t nb_pkts;
>> +       int i;
>>
>>         nb_pkts = rte_kni_rx_burst(kni, bufs, nb_bufs);
>> +       for (i = 0; i < nb_pkts; i++)
>> +               bufs[i]->port = kni_q->internals->port_id;
>>
>>         kni_q->rx.pkts += nb_pkts;
>>
>> @@ -372,6 +376,7 @@ eth_kni_create(struct rte_vdev_device *vdev,
>>                 return NULL;
>>
>>         internals = eth_dev->data->dev_private;
>> +       internals->port_id = eth_dev->data->port_id;
>>         data = eth_dev->data;
>>         data->nb_rx_queues = 1;
>>         data->nb_tx_queues = 1;
>> --
>> 2.25.4
>>
> 
> 
>
  
Ferruh Yigit July 29, 2020, 10:28 p.m. UTC | #3
On 7/29/2020 6:06 PM, Ferruh Yigit wrote:
> On 7/29/2020 6:02 PM, David Marchand wrote:
>> On Fri, Jul 24, 2020 at 5:10 PM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>>>
>>> From: jiancheng pei <jpei@sonicwall.com>
>>>
>>> Store port_id in pmd_internals when eth kni device is created.
>>> Then set packet port of rte_mbuf in function eth_kni_rx.
>>
>> LGTM.
>>
>> Is this fix worth a backport?
> 
> Makes sense, +1 to add stable tag.
> 
>> A net driver is expected to set the port in all mbufs (m->port is
>> initialised/reset to MBUF_INVALID_PORT).
>>
>>
>>>
>>> Signed-off-by: Jecky Pei <jpei@sonicwall.com>
>>> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Cc: stable@dpdk.org

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index cde98f0bb2..831fe96c96 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -47,6 +47,7 @@  struct pmd_queue {
 
 struct pmd_internals {
 	struct rte_kni *kni;
+	uint16_t port_id;
 	int is_kni_started;
 
 	pthread_t thread;
@@ -78,8 +79,11 @@  eth_kni_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 	struct pmd_queue *kni_q = q;
 	struct rte_kni *kni = kni_q->internals->kni;
 	uint16_t nb_pkts;
+	int i;
 
 	nb_pkts = rte_kni_rx_burst(kni, bufs, nb_bufs);
+	for (i = 0; i < nb_pkts; i++)
+		bufs[i]->port = kni_q->internals->port_id;
 
 	kni_q->rx.pkts += nb_pkts;
 
@@ -372,6 +376,7 @@  eth_kni_create(struct rte_vdev_device *vdev,
 		return NULL;
 
 	internals = eth_dev->data->dev_private;
+	internals->port_id = eth_dev->data->port_id;
 	data = eth_dev->data;
 	data->nb_rx_queues = 1;
 	data->nb_tx_queues = 1;