Re: [dpdk-dev] [PATCH 01/13] examples/eventdev: add Rx adapter support

2017-12-12 Thread Pavan Nikhilesh Bhagavatula
On Mon, Dec 11, 2017 at 04:15:41PM +, Eads, Gage wrote:
> Hi Pavan,
>
> 
>
> >  static inline void
> >  schedule_devices(unsigned int lcore_id)  {
> > if (fdata->rx_core[lcore_id] && (fdata->rx_single ||
> > rte_atomic32_cmpset(&(fdata->rx_lock), 0, 1))) {
> > -   producer();
> > +   rte_service_run_iter_on_app_lcore(fdata->rxadptr_service_id,
> > 1);
> > rte_atomic32_clear((rte_atomic32_t *)&(fdata->rx_lock));
> > }
>
> The (rx_single || cmpset(rx_lock)) check should no longer be needed -- this 
> logic is provided in rte_service_run_iter_on_app_lcore() and service_run(). 
> The rx_lock can be dropped in general.
>

we could either remove the example level locks (or) keep the locks at
application level and disable them in service api through
rte_service_run_iter_on_app_lcore(, 0).

If we choose to remove example level locks we could do something like
rte_service_run_iter_on_app_lcore(id, !rx_single)

> 
>
> > +   if (port_needed)
> > +   prod_data.port_id = cons_data.port_id + 1;
> > +   prod_data.dev_id = evdev_id;
> > +   prod_data.qid = cdata.qid[0];
> > +
>
> Is prod_data still needed? Looks like we're only using it in main() to print 
> the port ID (which may not be valid, depending on if port_needed is true).

Prod data is not needed I left it there to be consistent with the old example,
I will clean it up in the next version.

>
> Thanks,
> Gage

Thanks,
Pavan


Re: [dpdk-dev] [PATCH 02/13] examples/eventdev: move common data into pipeline common

2017-12-12 Thread Pavan Nikhilesh Bhagavatula
On Mon, Dec 11, 2017 at 04:15:48PM +, Eads, Gage wrote:
> Hi Pavan,
>
> 
>
> > @@ -2,6 +2,7 @@
> >   *   BSD LICENSE
> >   *
> >   *   Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
> > + *   Copyright 2016 Cavium, Inc.
>
> Should this be 2017? Same for the copyright dates in pipeline_common.h.

Agreed, will modify in the next version.

Thanks,
Pavan.


[dpdk-dev] [PATCH v5] examples/ipsec-secgw: fix usage of incorrect port

2017-12-12 Thread Anoob Joseph
When security offload is enabled, the packet should be forwarded on the
port configured in the SA. Security session will be configured on that
port only, and sending the packet on other ports could result in
unencrypted packets being sent out.

This would have performance improvements too, as the per packet LPM
lookup would be avoided for IPsec packets, in inline mode.

Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")

Signed-off-by: Anoob Joseph 
Acked-by: Akhil Goyal 
---
v5
* Updated comments as suggested by Akhil

v4
* Made get_hop_for_offload_pkt() be aware of the packet type (ipv4/ipv6) and
  return success/error values accordingly

v3
* Bug fix (fixed a wrong if condition)
* Minor changes in documentation

v2:
* Updated documentation with the change in behavior for outbound inline
  offloaded packets.

 doc/guides/sample_app_ug/ipsec_secgw.rst |  10 ++-
 examples/ipsec-secgw/ipsec-secgw.c   | 101 ++-
 2 files changed, 96 insertions(+), 15 deletions(-)

diff --git a/doc/guides/sample_app_ug/ipsec_secgw.rst 
b/doc/guides/sample_app_ug/ipsec_secgw.rst
index d6cfdbf..ae18acd 100644
--- a/doc/guides/sample_app_ug/ipsec_secgw.rst
+++ b/doc/guides/sample_app_ug/ipsec_secgw.rst
@@ -61,6 +61,12 @@ In case of complete protocol offload, the processing of 
headers(ESP and outer
 IP header) is done by the hardware and the application does not need to
 add/remove them during outbound/inbound processing.
 
+For inline offloaded outbound traffic, the application will not do the LPM
+lookup for routing, as the port on which the packet has to be forwarded will be
+part of the SA. Security parameters will be configured on that port only, and
+sending the packet on other ports could result in unencrypted packets being
+sent out.
+
 The Path for IPsec Inbound traffic is:
 
 *  Read packets from the port.
@@ -543,7 +549,9 @@ where each options means:
  
 
  * Port/device ID of the ethernet/crypto accelerator for which the SA is
-   configured. This option is used when *type* is NOT *no-offload*
+   configured. For *inline-crypto-offload* and *inline-protocol-offload*, this
+   port will be used for routing. The routing table will not be referred in
+   this case.
 
  * Optional: No, if *type* is not *no-offload*
 
diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index c98454a..2a406ab 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -585,31 +585,81 @@ process_pkts_outbound_nosp(struct ipsec_ctx *ipsec_ctx,
traffic->ip6.num = nb_pkts_out;
 }
 
+static inline int32_t
+get_hop_for_offload_pkt(struct rte_mbuf *pkt, int is_ipv6)
+{
+   struct ipsec_mbuf_metadata *priv;
+   struct ipsec_sa *sa;
+
+   priv = get_priv(pkt);
+
+   sa = priv->sa;
+   if (unlikely(sa == NULL)) {
+   RTE_LOG(ERR, IPSEC, "SA not saved in private data\n");
+   goto fail;
+   }
+
+   if (is_ipv6)
+   return sa->portid;
+
+   /* else */
+   return (sa->portid | RTE_LPM_LOOKUP_SUCCESS);
+
+fail:
+   if (is_ipv6)
+   return -1;
+
+   /* else */
+   return 0;
+}
+
 static inline void
 route4_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[], uint8_t nb_pkts)
 {
uint32_t hop[MAX_PKT_BURST * 2];
uint32_t dst_ip[MAX_PKT_BURST * 2];
+   int32_t pkt_hop = 0;
uint16_t i, offset;
+   uint16_t lpm_pkts = 0;
 
if (nb_pkts == 0)
return;
 
+   /* Need to do an LPM lookup for non-inline packets. Inline packets will
+* have port ID in the SA
+*/
+
for (i = 0; i < nb_pkts; i++) {
-   offset = offsetof(struct ip, ip_dst);
-   dst_ip[i] = *rte_pktmbuf_mtod_offset(pkts[i],
-   uint32_t *, offset);
-   dst_ip[i] = rte_be_to_cpu_32(dst_ip[i]);
+   if (!(pkts[i]->ol_flags & PKT_TX_SEC_OFFLOAD)) {
+   /* Security offload not enabled. So an LPM lookup is
+* required to get the hop
+*/
+   offset = offsetof(struct ip, ip_dst);
+   dst_ip[lpm_pkts] = *rte_pktmbuf_mtod_offset(pkts[i],
+   uint32_t *, offset);
+   dst_ip[lpm_pkts] = rte_be_to_cpu_32(dst_ip[lpm_pkts]);
+   lpm_pkts++;
+   }
}
 
-   rte_lpm_lookup_bulk((struct rte_lpm *)rt_ctx, dst_ip, hop, nb_pkts);
+   rte_lpm_lookup_bulk((struct rte_lpm *)rt_ctx, dst_ip, hop, lpm_pkts);
+
+   lpm_pkts = 0;
 
for (i = 0; i < nb_pkts; i++) {
-   if ((hop[i] & RTE_LPM_LOOKUP_SUCCESS) == 0) {
+   if (pkts[i]->ol_flags & PKT_TX_SEC_OFFLOAD) {
+   /* Read hop from the SA */
+   pkt_hop = get_hop_for_offload_pkt(pkts[i], 0);
+   } else {
+

Re: [dpdk-dev] [PATCH] vhost_user: protect active rings from async ring changes

2017-12-12 Thread Maxime Coquelin



On 12/12/2017 06:25 AM, Tan, Jianfeng wrote:




-Original Message-
From: Maxime Coquelin [mailto:maxime.coque...@redhat.com]
Sent: Friday, December 8, 2017 6:12 PM
To: Tan, Jianfeng; Victor Kaplansky; dev@dpdk.org; y...@fridaylinux.org; Bie,
Tiwei
Cc: sta...@dpdk.org; jfrei...@redhat.com
Subject: Re: [PATCH] vhost_user: protect active rings from async ring
changes

Hi Jianfeng,

On 12/08/2017 09:51 AM, Tan, Jianfeng wrote:




-Original Message-
From: Maxime Coquelin [mailto:maxime.coque...@redhat.com]
Sent: Friday, December 8, 2017 4:36 PM
To: Tan, Jianfeng; Victor Kaplansky; dev@dpdk.org; y...@fridaylinux.org;

Bie,

Tiwei
Cc: sta...@dpdk.org; jfrei...@redhat.com
Subject: Re: [PATCH] vhost_user: protect active rings from async ring
changes



On 12/08/2017 03:14 AM, Tan, Jianfeng wrote:




-Original Message-
From: Maxime Coquelin [mailto:maxime.coque...@redhat.com]
Sent: Thursday, December 7, 2017 6:02 PM
To: Tan, Jianfeng; Victor Kaplansky; dev@dpdk.org;

y...@fridaylinux.org;

Bie,

Tiwei
Cc: sta...@dpdk.org; jfrei...@redhat.com
Subject: Re: [PATCH] vhost_user: protect active rings from async ring
changes



On 12/07/2017 10:33 AM, Tan, Jianfeng wrote:




-Original Message-
From: Victor Kaplansky [mailto:vkapl...@redhat.com]
Sent: Wednesday, December 6, 2017 9:56 PM
To: dev@dpdk.org; y...@fridaylinux.org; Bie, Tiwei; Tan, Jianfeng;
vkapl...@redhat.com
Cc: sta...@dpdk.org; jfrei...@redhat.com; Maxime Coquelin
Subject: [PATCH] vhost_user: protect active rings from async ring

changes


When performing live migration or memory hot-plugging,
the changes to the device and vrings made by message handler
done independently from vring usage by PMD threads.

This causes for example segfauls during live-migration


segfauls ->segfaults?


with MQ enable, but in general virtually any request
sent by qemu changing the state of device can cause
problems.

These patches fixes all above issues by adding a spinlock
to every vring and requiring message handler to start operation
only after ensuring that all PMD threads related to the divece


Another typo: divece.


are out of critical section accessing the vring data.

Each vring has its own lock in order to not create contention
between PMD threads of different vrings and to prevent
performance degradation by scaling queue pair number.


Also wonder how much overhead it brings.

Instead of locking each vring, can we just, waiting a while (10us for

example)

after call destroy_device() callback so that every PMD thread has

enough

time to skip out the criterial area?

No, because we are not destroying the device when it is needed.
Actually, once destroy_device() is called, it is likely that the
application has taken care the ring aren't being processed anymore
before returning from the callback (This is at least the case with Vhost
PMD).


OK, I did not put it right way as there are multiple cases above: migration

and memory hot plug. Let me try again:


Whenever a vhost thread handles a message affecting PMD threads,

(like

SET_MEM_TABLE, GET_VRING_BASE, etc) we can remove the dev flag -
VIRTIO_DEV_RUNNING, and wait for a while so that PMD threads skip out

of

those criterial area. After message handling, reset the flag -
VIRTIO_DEV_RUNNING.

I think you mean clearing vq's enabled flag, because PMD threads never
check the VIRTIO_DEV_RUNNING flag.


Ah, yes.




I suppose it can work, basing on an assumption that PMD threads work

in

polling mode and can skip criterial area quickly and inevitably.

That sounds very fragile, because if the CPU aren't perfectly isolated,
your PMD thread can be preempted for interrupt handling for example.

Or what if for some reason the PMD thread CPU stalls for a short while?

The later is unlikely, but if it happens, it will be hard to debug.

Let's see first the performance impact of using the spinlock. It might
not be that important because 99.% of the times, it will not even
spin.


Fair enough.


I did some benchmarks on my Broadwell test bench (see patch below), and
it seems that depending on the benchmark, perfs are on par, or better
with the spinlock! I guess it explains because with the spinlock there
is a better batching and less concurrent accesses on the rings, but I'm
not sure.

Please find my results below (CPU E5-2667 v4 @ 3.20GHz):

Bench v17.11 v17.11 + spinlock
    --- ---
PVP Bidir run1   19.29Mpps   19.26Mpps
PVP Bidir run2   19.26Mpps   19.28Mpps
TxOnly   18.47Mpps   18.83Mpps
RxOnly   13.83Mpps   13.83Mpps
IO Loopback  7.94Mpps7.97Mpps



This number seems really good for throughput.

FYI, we are recently doing a test to measure how long it takes for a noop 
(means there is no packets on the virtqueue) vhost dequeue operation. It's like:

 start_tsc = rte_rdtsc();
 for (j = 0; j < 1000; ++j)
 nb_rx = rte_eth_rx_burst(port_id, queue_id, pkts_

Re: [dpdk-dev] [PATCH 14/39] examples/ip_reassembly: convert to new ethdev offloads API

2017-12-12 Thread Ananyev, Konstantin


> -Original Message-
> From: Shahaf Shuler [mailto:shah...@mellanox.com]
> Sent: Tuesday, December 12, 2017 6:31 AM
> To: Ananyev, Konstantin ; dev@dpdk.org; 
> Nicolau, Radu 
> Subject: RE: [dpdk-dev] [PATCH 14/39] examples/ip_reassembly: convert to new 
> ethdev offloads API
> 
> Monday, December 11, 2017 5:04 PM, Ananyev, Konstantin:
> > > + if ((dev_info.tx_offload_capa & port_conf.txmode.offloads)
> > !=
> > > + port_conf.txmode.offloads) {
> > > + printf("Some Tx offloads are not supported "
> > > +"by port %d: requested 0x%lx supported
> > 0x%lx\n",
> > > +portid, port_conf.txmode.offloads,
> > > +dev_info.tx_offload_capa);
> > > + port_conf.txmode.offloads &=
> > dev_info.tx_offload_capa;
> > > + }
> >
> > Sort of generic question regarding most examples - wouldn't it be better to
> > do rte_exit() if device doesn't support the offloads we expect instead of
> > masking off unsupported offloads and continue?
> > Konstantin
> 
> We already started to discuss this question, see [1].
> 
> I agree that it is wrong approach to mask the not supported offloads and 
> continue the application.
> So now I we have 2 options:
> 1. report the warning and let the PMD to fail the device configuration.
> 2. like you suggested, report the error and exit the application.
> 
> While it is wrong for application to set offloads which are not reported by 
> the device capabilities, the input I got from Radu is that there are
> a lot of PMDs that will break with option 2, see [1].
> One example is ixgbe which expects to have CRC offload enabled with IPSEC but 
> don't report it on its caps.
> 
> So my current direction is to make the examples less strict, and give the 
> option for the PMD to fail those if not supported.
> Any objection?

So basically option #1 from the above?
If so, none from me.

> 
> [1] http://dpdk.org/ml/archives/dev/2017-December/083441.html
> 



Re: [dpdk-dev] [PATCH v3 1/2] lib/security: add support for get metadata

2017-12-12 Thread Akhil Goyal

Hi Anoob,

On 12/11/2017 12:51 PM, Anoob wrote:

Hi Akhil,

Can you confirm if you are fine with the approach explained inline.

Thanks,
Anoob

On 12/06/2017 03:13 PM, Radu Nicolau wrote:

Hi,


On 12/6/2017 7:30 AM, Anoob wrote:

Hi Akhil, Radu,

Please see inline.

Thanks,

Anoob


On 11/24/2017 05:33 PM, Akhil Goyal wrote:

On 11/24/2017 5:29 PM, Radu Nicolau wrote:



On 11/24/2017 11:34 AM, Akhil Goyal wrote:

Hi Radu,
On 11/24/2017 4:47 PM, Radu Nicolau wrote:



On 11/24/2017 10:55 AM, Akhil Goyal wrote:

On 11/24/2017 3:09 PM, Radu Nicolau wrote:

Hi,

Comment inline


On 11/24/2017 8:50 AM, Akhil Goyal wrote:

Hi Anoob, Radu,
On 11/23/2017 4:49 PM, Anoob Joseph wrote:
In case of inline protocol processed ingress traffic, the 
packet may not
have enough information to determine the security parameters 
with which
the packet was processed. In such cases, application could 
get metadata
from the packet which could be used to identify the security 
parameters

with which the packet was processed.

Signed-off-by: Anoob Joseph 
---
v3:
* Replaced 64 bit metadata in conf with (void *)userdata
* The API(rte_security_get_pkt_metadata) would return void * 
instead of

   uint64_t

v2:
* Replaced get_session and get_cookie APIs with 
get_pkt_metadata API


  lib/librte_security/rte_security.c    | 13 +
  lib/librte_security/rte_security.h    | 19 
+++
  lib/librte_security/rte_security_driver.h | 16 


  3 files changed, 48 insertions(+)

diff --git a/lib/librte_security/rte_security.c 
b/lib/librte_security/rte_security.c

index 1227fca..a1d78b6 100644
--- a/lib/librte_security/rte_security.c
+++ b/lib/librte_security/rte_security.c
@@ -108,6 +108,19 @@ rte_security_set_pkt_metadata(struct 
rte_security_ctx *instance,

 sess, m, params);
  }
  +void *
+rte_security_get_pkt_metadata(struct rte_security_ctx 
*instance,

+  struct rte_mbuf *pkt)
Can we rename pkt with m. Just to make it consistent with the 
set API.

+{
+    void *md = NULL;
+
+ RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->get_pkt_metadata, 
NULL);
+    if (instance->ops->get_pkt_metadata(instance->device, 
pkt, &md))

+    return NULL;
+
+    return md;
+}


Pkt metadata should be set by user i.e. the application, and 
the driver need not be aware of the format and the values of 
the metadata.
So setting the metadata in the driver and getting it back from 
the driver does not look a good idea.


Is it possible, that the application define the metadata on 
its own and set it in the library itself without the call to 
the driver ops.
I'm not sure I understand here; even in our case (ixgbe) the 
driver sets the metadata and it is aware of the format - that 
is the whole idea. This is why we added the set_metadata API, 
to allow the driver to inject extra information into the mbuf, 
information that is driver specific and derived from the 
security session, so it makes sense to also have a symmetric 
get_metadata.
Private data is the one that follows those rules, i.e. 
application specific and driver transparent.


As per my understanding of the user metadata, it should be in 
control of the application, and the application shall know the 
format of that. Setting in driver will disallow this.

Please let me know if my understanding is incorrect.

If at all, some information is needed to be set on the basis of 
driver, then application can get that information from the 
driver and then set it in the packet metadata in its own 
way/format.


The rte_security_set_pkt_metadata() doc defines the metadata as 
"device-specific defined metadata" and also takes a device 
specific params pointer, so the symmetric function is to be 
expected to work in the same way, i.e. return device specific 
metadata associated with the security session and instance and 
mbuf. How is this metadata stored is not specified in the 
security API, so the PMD implementation have the flexibility.
Is rte_security_get_pkt_metadata() expected to return a "device 
specific" pointer? If that's the case, we would need another call 
(something like, rte_security_get_userdata()) to get back the 
userdata, right? Or is it fine, if the application assumes it will 
get userdata (the one passed in conf while creating security session) 
with rte_security_get_pkt_metadata()?
Yes, this will be my assumption, a "device specific" pointer (similar 
to the "void *params" parameter of the rte_security_set_pkt_metadata 
function), which will contain an arbitrary defined structure that will 
be decoded by calling a PMD defined function.

But I think Akhil has a different view on this.
I am ok with the approach, if we are adding this as a limitation of 
using udata in the documentation for inline cases.


The ideal approach should be such that driver should not be knowing the 
content of the udata. But, if we cannot do away with it, we can mention 
it in the documentation.






Yes it was defined that way

[dpdk-dev] [PATCH v2] eventdev: use links map to unlink queues

2017-12-12 Thread Pavan Nikhilesh
The octeontx event device doesn't store the queues to port mapping as a
result it cannot return the exact number of queues unlinked from a port
when application wants to unlink all the queues mapped (supplies queues
param as NULL).

Using links_map we can determine the exact queues mapped to a specific
port and unlink them.

Signed-off-by: Pavan Nikhilesh 
---
 lib/librte_eventdev/rte_eventdev.c | 33 ++---
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/lib/librte_eventdev/rte_eventdev.c 
b/lib/librte_eventdev/rte_eventdev.c
index e0c2a78..b43ffbf 100644
--- a/lib/librte_eventdev/rte_eventdev.c
+++ b/lib/librte_eventdev/rte_eventdev.c
@@ -888,7 +888,8 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
 {
struct rte_eventdev *dev;
uint8_t all_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
-   int i, diag;
+   uint8_t linked_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
+   int i, diag, j;
uint16_t *links_map;
 
RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, -EINVAL, 0);
@@ -906,13 +907,34 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
return 0;
}
 
+   links_map = dev->data->links_map;
+   /* Point links_map to this port specific area */
+   links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
+
if (queues == NULL) {
-   for (i = 0; i < dev->data->nb_queues; i++)
-   all_queues[i] = i;
+   j = 0;
+   for (i = 0; i < dev->data->nb_queues; i++) {
+   if (links_map[i] !=
+   EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
+   all_queues[j] = i;
+   j++;
+   }
+   }
queues = all_queues;
-   nb_unlinks = dev->data->nb_queues;
+   } else {
+   j = 0;
+   for (i = 0; i < nb_unlinks; i++) {
+   if (links_map[queues[i]] ==
+   EVENT_QUEUE_SERVICE_PRIORITY_INVALID)
+   break;
+
+   linked_queues[j] = queues[i];
+   j++;
+   }
+   queues = linked_queues;
}
 
+   nb_unlinks = j;
for (i = 0; i < nb_unlinks; i++)
if (queues[i] >= dev->data->nb_queues) {
rte_errno = -EINVAL;
@@ -925,9 +947,6 @@ rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
if (diag < 0)
return diag;
 
-   links_map = dev->data->links_map;
-   /* Point links_map to this port specific area */
-   links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
for (i = 0; i < diag; i++)
links_map[queues[i]] = EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
 
-- 
2.7.4



[dpdk-dev] [PATCH v2 0/4] meter: add meter configuration profile api

2017-12-12 Thread Jasvinder Singh
This patch set adds support for meter configuration profiles.
Benefits: simplified configuration procedure, improved performance.

Q1: What is the configuration profile and why does it make sense?
A1: The configuration profile represents the set of configuration
parameters for a given meter object, such as the rates and sizes for
the token buckets. The configuration profile concept makes sense when
many meter objects share the same configuration, which is the typical
usage model: thousands of traffic flows are each individually metered
according to just a few service levels (i.e. profiles).

Q2: How is the configuration profile improving the performance?
A2: The performance improvement is achieved by reducing the memory
footprint of a meter object, which results in better cache utilization
for the typical case when large arrays of meter objects are used. The
internal data structures stored for each meter object contain:
   a) Constant fields: Low level translation of the configuration
  parameters that does not change post-configuration. This is
  really duplicated for all meters that use the same
  configuration. This is the configuration profile data that is
  moved away from the meter object. Current size (implementation
  dependent): srTCM = 32 bytes, trTCM = 32 bytes.
   b) Variable fields: Time stamps and running counters that change
  during the on-going traffic metering process. Current size
  (implementation dependant): srTCM = 24 bytes, trTCM = 32 bytes.
  Therefore, by moving the constant fields to a separate profile
  data structure shared by all the meters with the same
  configuration, the size of the meter object is reduced by ~50%.

Cristian Dumitrescu (3):
  lib/librte_meter: add meter configuration profile
  test/test_meter: update meter test
  examples/qos_meter: accommodate meter api changes

Jasvinder Singh (1):
  examples/ip_pipeline: update flow action pipeline

 doc/guides/rel_notes/deprecation.rst   |   3 -
 doc/guides/rel_notes/release_18_02.rst |   2 +-
 .../pipeline/pipeline_flow_actions_be.c|  25 ++-
 examples/qos_meter/main.c  |  39 +++-
 examples/qos_meter/main.h  |  32 ++--
 lib/librte_meter/Makefile  |   2 +-
 lib/librte_meter/rte_meter.c   |  95 ++
 lib/librte_meter/rte_meter.h   | 197 ++---
 lib/librte_meter/rte_meter_version.map |   8 +
 test/test/test_meter.c | 194 +++-
 10 files changed, 394 insertions(+), 203 deletions(-)

-- 
2.9.3



[dpdk-dev] [PATCH v2 3/4] examples/qos_meter: accommodate meter api changes

2017-12-12 Thread Jasvinder Singh
From: Cristian Dumitrescu 

Modify the sample application to adapt the api changes.

Signed-off-by: Cristian Dumitrescu 
---
 examples/qos_meter/main.c | 39 ++-
 examples/qos_meter/main.h | 32 
 2 files changed, 50 insertions(+), 21 deletions(-)

diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index 67b4a75..23908f0 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -121,14 +121,23 @@ static uint16_t port_tx;
 static struct rte_mbuf *pkts_rx[PKT_RX_BURST_MAX];
 struct rte_eth_dev_tx_buffer *tx_buffer;
 
-struct rte_meter_srtcm_params app_srtcm_params[] = {
-   {.cir = 100 * 46,  .cbs = 2048, .ebs = 2048},
+struct rte_meter_srtcm_params app_srtcm_params = {
+   .cir = 100 * 46,
+   .cbs = 2048,
+   .ebs = 2048
 };
 
-struct rte_meter_trtcm_params app_trtcm_params[] = {
-   {.cir = 100 * 46,  .pir = 150 * 46,  .cbs = 2048, .pbs = 2048},
+struct rte_meter_srtcm_profile app_srtcm_profile;
+
+struct rte_meter_trtcm_params app_trtcm_params = {
+   .cir = 100 * 46,
+   .pir = 150 * 46,
+   .cbs = 2048,
+   .pbs = 2048
 };
 
+struct rte_meter_trtcm_profile app_trtcm_profile;
+
 #define APP_FLOWS_MAX  256
 
 FLOW_METER app_flows[APP_FLOWS_MAX];
@@ -136,12 +145,21 @@ FLOW_METER app_flows[APP_FLOWS_MAX];
 static int
 app_configure_flow_table(void)
 {
-   uint32_t i, j;
+   uint32_t i;
int ret;
 
-   for (i = 0, j = 0; i < APP_FLOWS_MAX;
-   i ++, j = (j + 1) % RTE_DIM(PARAMS)) {
-   ret = FUNC_CONFIG(&app_flows[i], &PARAMS[j]);
+   ret = rte_meter_srtcm_profile_config(&app_srtcm_profile,
+   &app_srtcm_params);
+   if (ret)
+   return ret;
+
+   ret = rte_meter_trtcm_profile_config(&app_trtcm_profile,
+   &app_trtcm_params);
+   if (ret)
+   return ret;
+
+   for (i = 0; i < APP_FLOWS_MAX; i++) {
+   ret = FUNC_CONFIG(&app_flows[i], &PROFILE);
if (ret)
return ret;
}
@@ -166,7 +184,10 @@ app_pkt_handle(struct rte_mbuf *pkt, uint64_t time)
enum policer_action action;
 
/* color input is not used for blind modes */
-   output_color = (uint8_t) FUNC_METER(&app_flows[flow_id], time, pkt_len,
+   output_color = (uint8_t) FUNC_METER(&app_flows[flow_id],
+   &PROFILE,
+   time,
+   pkt_len,
(enum rte_meter_color) input_color);
 
/* Apply policing and set the output color */
diff --git a/examples/qos_meter/main.h b/examples/qos_meter/main.h
index 54867dc..bff97a4 100644
--- a/examples/qos_meter/main.h
+++ b/examples/qos_meter/main.h
@@ -50,44 +50,52 @@ enum policer_action 
policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
 
 #if APP_MODE == APP_MODE_FWD
 
-#define FUNC_METER(a,b,c,d) color, flow_id=flow_id, pkt_len=pkt_len, time=time
+#define FUNC_METER(m, p, time, pkt_len, pkt_color) \
+({ \
+   void *mp = m;   \
+   void *pp = p;   \
+   mp = mp;\
+   pp = pp;\
+   time = time;\
+   pkt_len = pkt_len;  \
+   pkt_color;  \
+})
 #define FUNC_CONFIG(a, b) 0
-#define PARAMS app_srtcm_params
 #define FLOW_METER int
+#define PROFILEapp_srtcm_profile
 
 #elif APP_MODE == APP_MODE_SRTCM_COLOR_BLIND
 
-#define FUNC_METER(a,b,c,d) rte_meter_srtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color) \
+   rte_meter_srtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMSapp_srtcm_params
 #define FLOW_METERstruct rte_meter_srtcm
+#define PROFILE   app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_SRTCM_COLOR_AWARE)
 
 #define FUNC_METERrte_meter_srtcm_color_aware_check
 #define FUNC_CONFIG   rte_meter_srtcm_config
-#define PARAMSapp_srtcm_params
 #define FLOW_METERstruct rte_meter_srtcm
+#define PROFILE   app_srtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_BLIND)
 
-#define FUNC_METER(a,b,c,d) rte_meter_trtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color) \
+   rte_meter_trtcm_color_blind_check(m, p, time, pkt_len)
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS   app_trtcm_params
 #define FLOW_METER   struct rte_meter_trtcm
+#define PROFILE  app_trtcm_profile
 
 #elif (APP_MODE == APP_MODE_TRTCM_COLOR_AWARE)
 
-#define FUNC_METER   rte_meter_trtcm_color_aware_check
+#define FUNC_METER rte_meter_trtcm_color_aware_check
 #define FUNC_CONFIG  rte_meter_trtcm_config
-#define PARAMS   app_trtc

[dpdk-dev] [PATCH v2 4/4] examples/ip_pipeline: update flow action pipeline

2017-12-12 Thread Jasvinder Singh
Update flow action pipeline to conform the meter api changes.

Signed-off-by: Jasvinder Singh 
---
 .../pipeline/pipeline_flow_actions_be.c| 25 +-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c 
b/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
index 11fcbb7..8874f04 100644
--- a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
@@ -140,6 +140,7 @@ static pipeline_msg_req_handler custom_handlers[] = {
  */
 struct meter_policer {
struct rte_meter_trtcm meter;
+   struct rte_meter_trtcm_profile meter_profile;
struct pipeline_fa_policer_params policer;
struct pipeline_fa_policer_stats stats;
 };
@@ -156,8 +157,15 @@ flow_table_entry_set_meter(struct flow_table_entry *entry,
 {
struct rte_meter_trtcm *meter = &entry->mp[meter_id].meter;
struct rte_meter_trtcm_params *meter_params = ¶ms->m[meter_id];
+   struct rte_meter_trtcm_profile *meter_profile =
+   &entry->mp[meter_id].meter_profile;
+   int status;
 
-   return rte_meter_trtcm_config(meter, meter_params);
+   status = rte_meter_trtcm_profile_config(meter_profile, meter_params);
+   if (status)
+   return status;
+
+   return rte_meter_trtcm_config(meter, meter_profile);
 }
 
 static void
@@ -231,11 +239,14 @@ pkt_work(
enum rte_meter_color color = p->dscp[dscp].color;
 
struct rte_meter_trtcm *meter = &entry->mp[tc].meter;
+   struct rte_meter_trtcm_profile *meter_profile =
+   &entry->mp[tc].meter_profile;
struct pipeline_fa_policer_params *policer = &entry->mp[tc].policer;
struct pipeline_fa_policer_stats *stats = &entry->mp[tc].stats;
 
/* Read (entry), compute */
enum rte_meter_color color2 = rte_meter_trtcm_color_aware_check(meter,
+   meter_profile,
time,
total_length,
color);
@@ -313,42 +324,54 @@ pkt4_work(
enum rte_meter_color color3 = p->dscp[dscp3].color;
 
struct rte_meter_trtcm *meter0 = &entry0->mp[tc0].meter;
+   struct rte_meter_trtcm_profile *meter0_profile =
+   &entry0->mp[tc0].meter_profile;
struct pipeline_fa_policer_params *policer0 = &entry0->mp[tc0].policer;
struct pipeline_fa_policer_stats *stats0 = &entry0->mp[tc0].stats;
 
struct rte_meter_trtcm *meter1 = &entry1->mp[tc1].meter;
+   struct rte_meter_trtcm_profile *meter1_profile =
+   &entry1->mp[tc1].meter_profile;
struct pipeline_fa_policer_params *policer1 = &entry1->mp[tc1].policer;
struct pipeline_fa_policer_stats *stats1 = &entry1->mp[tc1].stats;
 
struct rte_meter_trtcm *meter2 = &entry2->mp[tc2].meter;
+   struct rte_meter_trtcm_profile *meter2_profile =
+   &entry2->mp[tc2].meter_profile;
struct pipeline_fa_policer_params *policer2 = &entry2->mp[tc2].policer;
struct pipeline_fa_policer_stats *stats2 = &entry2->mp[tc2].stats;
 
struct rte_meter_trtcm *meter3 = &entry3->mp[tc3].meter;
+   struct rte_meter_trtcm_profile *meter3_profile =
+   &entry3->mp[tc3].meter_profile;
struct pipeline_fa_policer_params *policer3 = &entry3->mp[tc3].policer;
struct pipeline_fa_policer_stats *stats3 = &entry3->mp[tc3].stats;
 
/* Read (entry), compute, write (entry) */
enum rte_meter_color color2_0 = rte_meter_trtcm_color_aware_check(
meter0,
+   meter0_profile,
time,
total_length0,
color0);
 
enum rte_meter_color color2_1 = rte_meter_trtcm_color_aware_check(
meter1,
+   meter1_profile,
time,
total_length1,
color1);
 
enum rte_meter_color color2_2 = rte_meter_trtcm_color_aware_check(
meter2,
+   meter2_profile,
time,
total_length2,
color2);
 
enum rte_meter_color color2_3 = rte_meter_trtcm_color_aware_check(
meter3,
+   meter3_profile,
time,
total_length3,
color3);
-- 
2.9.3



[dpdk-dev] [PATCH v2 2/4] test/test_meter: update meter test

2017-12-12 Thread Jasvinder Singh
From: Cristian Dumitrescu 

Modify the unit test to accomodate the changes in the apis.

Signed-off-by: Cristian Dumitrescu 
---
 test/test/test_meter.c | 194 +
 1 file changed, 115 insertions(+), 79 deletions(-)

diff --git a/test/test/test_meter.c b/test/test/test_meter.c
index 26b0565..b6d133a 100644
--- a/test/test/test_meter.c
+++ b/test/test/test_meter.c
@@ -82,43 +82,43 @@ static inline int
 tm_test_srtcm_config(void)
 {
 #define SRTCM_CFG_MSG "srtcm_config"
-   struct rte_meter_srtcm sm;
+   struct rte_meter_srtcm_profile sp;
struct  rte_meter_srtcm_params sparams1;
 
/* invalid parameter test */
-   if(rte_meter_srtcm_config(NULL, NULL) == 0)
+   if (rte_meter_srtcm_profile_config(NULL, NULL) == 0)
melog(SRTCM_CFG_MSG);
-   if(rte_meter_srtcm_config(&sm, NULL) == 0)
+   if (rte_meter_srtcm_profile_config(&sp, NULL) == 0)
melog(SRTCM_CFG_MSG);
-   if(rte_meter_srtcm_config(NULL, &sparams) == 0)
+   if (rte_meter_srtcm_profile_config(NULL, &sparams) == 0)
melog(SRTCM_CFG_MSG);
 
/* cbs and ebs can't both be zero */
sparams1 = sparams;
sparams1.cbs = 0;
sparams1.ebs = 0;
-   if(rte_meter_srtcm_config(&sm, &sparams1) == 0)
+   if (rte_meter_srtcm_profile_config(&sp, &sparams1) == 0)
melog(SRTCM_CFG_MSG);
 
/* cir should never be 0 */
sparams1 = sparams;
sparams1.cir = 0;
-   if(rte_meter_srtcm_config(&sm, &sparams1) == 0)
+   if (rte_meter_srtcm_profile_config(&sp, &sparams1) == 0)
melog(SRTCM_CFG_MSG);
 
/* one of ebs and cbs can be zero, should be successful */
sparams1 = sparams;
sparams1.ebs = 0;
-   if(rte_meter_srtcm_config(&sm, &sparams1) != 0)
+   if (rte_meter_srtcm_profile_config(&sp, &sparams1) != 0)
melog(SRTCM_CFG_MSG);
 
sparams1 = sparams;
sparams1.cbs = 0;
-   if(rte_meter_srtcm_config(&sm, &sparams1) != 0)
+   if (rte_meter_srtcm_profile_config(&sp, &sparams1) != 0)
melog(SRTCM_CFG_MSG);
 
/* usual parameter, should be successful */
-   if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+   if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0)
melog(SRTCM_CFG_MSG);
 
return 0;
@@ -131,47 +131,47 @@ tm_test_srtcm_config(void)
 static inline int
 tm_test_trtcm_config(void)
 {
-   struct rte_meter_trtcm tm;
+   struct rte_meter_trtcm_profile tp;
struct  rte_meter_trtcm_params tparams1;
 #define TRTCM_CFG_MSG "trtcm_config"
 
/* invalid parameter test */
-   if(rte_meter_trtcm_config(NULL, NULL) == 0)
+   if (rte_meter_trtcm_profile_config(NULL, NULL) == 0)
melog(TRTCM_CFG_MSG);
-   if(rte_meter_trtcm_config(&tm, NULL) == 0)
+   if (rte_meter_trtcm_profile_config(&tp, NULL) == 0)
melog(TRTCM_CFG_MSG);
-   if(rte_meter_trtcm_config(NULL, &tparams) == 0)
+   if (rte_meter_trtcm_profile_config(NULL, &tparams) == 0)
melog(TRTCM_CFG_MSG);
 
/* cir, cbs, pir and pbs never be zero */
tparams1 = tparams;
tparams1.cir = 0;
-   if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+   if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
melog(TRTCM_CFG_MSG);
 
tparams1 = tparams;
tparams1.cbs = 0;
-   if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+   if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
melog(TRTCM_CFG_MSG);
 
tparams1 = tparams;
tparams1.pbs = 0;
-   if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+   if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
melog(TRTCM_CFG_MSG);
 
tparams1 = tparams;
tparams1.pir = 0;
-   if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+   if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
melog(TRTCM_CFG_MSG);
 
/* pir should be greater or equal to cir */
tparams1 = tparams;
tparams1.pir = tparams1.cir - 1;
-   if(rte_meter_trtcm_config(&tm, &tparams1) == 0)
+   if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0)
melog(TRTCM_CFG_MSG" pir < cir test");
 
/* usual parameter, should be successful */
-   if(rte_meter_trtcm_config(&tm, &tparams) != 0)
+   if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0)
melog(TRTCM_CFG_MSG);
 
return 0;
@@ -184,41 +184,50 @@ static inline int
 tm_test_srtcm_color_blind_check(void)
 {
 #define SRTCM_BLIND_CHECK_MSG "srtcm_blind_check"
+   struct rte_meter_srtcm_profile sp;
struct rte_meter_srtcm sm;
uint64_t time;
uint64_t hz = rte_get_tsc_hz();
 
/* Test green */
-   if(rte_meter_srtcm_config(&sm, &sparams) != 0)
+   if (rte_meter_srtcm_profi

[dpdk-dev] [PATCH v2 1/4] lib/librte_meter: add meter configuration profile

2017-12-12 Thread Jasvinder Singh
From: Cristian Dumitrescu 

This patch set adds api for meter configuration profiles. For a given
meter object, the parameters such as the rates and sizes for
the token buckets are defined as configuration profile parameters.
This helps in reducing the memory footprint of a meter object which
results in better cache utilization for the typical case when large
arrays of meter objects are used.

Signed-off-by: Cristian Dumitrescu 
---
v2:
- increment LIBABIVAR
- update release note and deprecation notice
- fix checkpatch errors

 doc/guides/rel_notes/deprecation.rst   |   3 -
 doc/guides/rel_notes/release_18_02.rst |   2 +-
 lib/librte_meter/Makefile  |   2 +-
 lib/librte_meter/rte_meter.c   |  95 +---
 lib/librte_meter/rte_meter.h   | 197 +++--
 lib/librte_meter/rte_meter_version.map |   8 ++
 6 files changed, 205 insertions(+), 102 deletions(-)

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index 13e8543..6ba5ffd 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -50,6 +50,3 @@ Deprecation Notices
   required the previous behavior can be configured using existing flow
   director APIs. There is no ABI/API break. This change will just remove a
   global configuration setting and require explicit configuration.
-
-* librte_meter: The API will change to accommodate configuration profiles.
-  Most of the API functions will have an additional opaque parameter.
diff --git a/doc/guides/rel_notes/release_18_02.rst 
b/doc/guides/rel_notes/release_18_02.rst
index 24b67bb..7343b74 100644
--- a/doc/guides/rel_notes/release_18_02.rst
+++ b/doc/guides/rel_notes/release_18_02.rst
@@ -141,7 +141,7 @@ The libraries prepended with a plus sign were incremented 
in this version.
  librte_lpm.so.2
  librte_mbuf.so.3
  librte_mempool.so.3
- librte_meter.so.1
+   + librte_meter.so.2
  librte_metrics.so.1
  librte_net.so.1
  librte_pci.so.1
diff --git a/lib/librte_meter/Makefile b/lib/librte_meter/Makefile
index bfeb5d6..d05fe39 100644
--- a/lib/librte_meter/Makefile
+++ b/lib/librte_meter/Makefile
@@ -44,7 +44,7 @@ LDLIBS += -lrte_eal
 
 EXPORT_MAP := rte_meter_version.map
 
-LIBABIVER := 1
+LIBABIVER := 2
 
 #
 # all source are stored in SRCS-y
diff --git a/lib/librte_meter/rte_meter.c b/lib/librte_meter/rte_meter.c
index 5e2dadb..9db7a4a 100644
--- a/lib/librte_meter/rte_meter.c
+++ b/lib/librte_meter/rte_meter.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -60,61 +60,82 @@ rte_meter_get_tb_params(uint64_t hz, uint64_t rate, 
uint64_t *tb_period, uint64_
 }
 
 int
-rte_meter_srtcm_config(struct rte_meter_srtcm *m, struct 
rte_meter_srtcm_params *params)
+rte_meter_srtcm_profile_config(struct rte_meter_srtcm_profile *p,
+   struct rte_meter_srtcm_params *params)
 {
-   uint64_t hz;
+   uint64_t hz = rte_get_tsc_hz();
 
/* Check input parameters */
-   if ((m == NULL) || (params == NULL)) {
-   return -1;
-   }
+   if ((p == NULL) ||
+   (params == NULL) ||
+   (params->cir == 0) ||
+   ((params->cbs == 0) && (params->ebs == 0)))
+   return -EINVAL;
 
-   if ((params->cir == 0) || ((params->cbs == 0) && (params->ebs == 0))) {
-   return -2;
-   }
+   /* Initialize srTCM run-time structure */
+   p->cbs = params->cbs;
+   p->ebs = params->ebs;
+   rte_meter_get_tb_params(hz, params->cir, &p->cir_period,
+   &p->cir_bytes_per_period);
+
+   return 0;
+}
+
+int
+rte_meter_srtcm_config(struct rte_meter_srtcm *m,
+   struct rte_meter_srtcm_profile *p)
+{
+   /* Check input parameters */
+   if ((m == NULL) || (p == NULL))
+   return -EINVAL;
 
/* Initialize srTCM run-time structure */
-   hz = rte_get_tsc_hz();
m->time = rte_get_tsc_cycles();
-   m->tc = m->cbs = params->cbs;
-   m->te = m->ebs = params->ebs;
-   rte_meter_get_tb_params(hz, params->cir, &m->cir_period, 
&m->cir_bytes_per_period);
-
-   RTE_LOG(INFO, METER, "Low level srTCM config: \n"
-   "\tCIR period = %" PRIu64 ", CIR bytes per period = %" PRIu64 
"\n",
-   m->cir_period, m->cir_bytes_per_period);
+   m->tc = p->cbs;
+   m->te = p->ebs;
 
return 0;
 }
 
 int
-rte_meter_trtcm_config(struct rte_meter_trtcm *m, struct 
rte_meter_trtcm_params *params)
+rte_meter_trtcm_profile_config(struct rte_meter_trtcm_profile *p,
+   struct rte_meter_trtcm_params *params)
 {
-   uint64_t hz;
+   uint64_t hz = rte_get_tsc_hz();
 
/* Check input parameters */
-   if ((m == NULL) || (params == NULL)) 

[dpdk-dev] [PATCH 3/3] examples/l3fwd-power: use device max burst size

2017-12-12 Thread Nikhil Agarwal
On some of the hardware e.g. DPAA, rx burst can only return
upto 16 packets, which causes the application to assume that
no more packets are present.

This patch modifies the application to use device published
packet burst size.

Signed-off-by: Nikhil Agarwal 
---
 examples/l3fwd-power/main.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index d80f663..000ac53 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -145,6 +145,7 @@
 #define RTE_TEST_TX_DESC_DEFAULT 512
 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
+static uint16_t max_pkt_burst = MAX_PKT_BURST;
 
 /* ethernet addresses of ports */
 static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
@@ -421,7 +422,7 @@ power_timer_cb(__attribute__((unused)) struct rte_timer 
*tim,
rte_power_freq_down(lcore_id);
}
else if ( (unsigned)(stats[lcore_id].nb_rx_processed /
-   stats[lcore_id].nb_iteration_looped) < MAX_PKT_BURST) {
+   stats[lcore_id].nb_iteration_looped) < max_pkt_burst) {
/**
 * scale down a step if average packet per iteration less
 * than expectation.
@@ -759,9 +760,9 @@ power_freq_scaleup_heuristic(unsigned lcore_id,
  * HW Rx queue size is 128 by default, Rx burst read at maximum 32 entries
  * per iteration
  */
-#define FREQ_GEAR1_RX_PACKET_THRESHOLD MAX_PKT_BURST
-#define FREQ_GEAR2_RX_PACKET_THRESHOLD (MAX_PKT_BURST*2)
-#define FREQ_GEAR3_RX_PACKET_THRESHOLD (MAX_PKT_BURST*3)
+#define FREQ_GEAR1_RX_PACKET_THRESHOLD max_pkt_burst
+#define FREQ_GEAR2_RX_PACKET_THRESHOLD (max_pkt_burst*2)
+#define FREQ_GEAR3_RX_PACKET_THRESHOLD (max_pkt_burst*3)
 #define FREQ_UP_TREND1_ACC   1
 #define FREQ_UP_TREND2_ACC   100
 #define FREQ_UP_THRESHOLD1
@@ -950,7 +951,7 @@ main_loop(__attribute__((unused)) void *dummy)
queueid = rx_queue->queue_id;
 
nb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst,
-   MAX_PKT_BURST);
+   max_pkt_burst);
 
stats[lcore_id].nb_rx_processed += nb_rx;
if (unlikely(nb_rx == 0)) {
@@ -1703,6 +1704,9 @@ main(int argc, char **argv)
dev_rxq_num = dev_info.max_rx_queues;
dev_txq_num = dev_info.max_tx_queues;
 
+   if (dev_info.max_burst_size &&
+   dev_info.max_burst_size < max_pkt_burst)
+   max_pkt_burst = dev_info.max_burst_size;
nb_rx_queue = get_port_n_rx_queues(portid);
if (nb_rx_queue > dev_rxq_num)
rte_exit(EXIT_FAILURE,
-- 
2.7.4



[dpdk-dev] [PATCH 1/3] ethdev: add max burst size to device info

2017-12-12 Thread Nikhil Agarwal
Currently, if the  rte_eth_rx_burst() function returns a value less than
*nb_pkts*, the application will assume that no more packets are present.

Some of the hw queue based hardware can only support smaller burst for RX
and TX and thus break the expectation of the rx_burst API.

This patch adds support to provide the maximum burst size that can be
supported by a given PMD. The dev_info is being memset to '0' in
rte_ethdev library. The value of '0' indicates that any value for burst
size can be supported i.e. no change for existing PMDs.

The application can now use the lowest available max_burst_size value
for rte_eth_rx_burst.

Signed-off-by: Nikhil Agarwal 
---
 lib/librte_ether/rte_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 341c2d6..3ab6f02 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1047,6 +1047,7 @@ struct rte_eth_dev_info {
/** Configured number of rx/tx queues */
uint16_t nb_rx_queues; /**< Number of RX queues. */
uint16_t nb_tx_queues; /**< Number of TX queues. */
+   uint16_t max_burst_size; /**< MAX burst size, 0 for no limit. */
 };
 
 /**
-- 
2.7.4



[dpdk-dev] [PATCH 2/3] net/dpaa: implement max burst size in dev info

2017-12-12 Thread Nikhil Agarwal
Signed-off-by: Nikhil Agarwal 
---
 drivers/net/dpaa/dpaa_ethdev.c | 1 +
 drivers/net/dpaa/dpaa_ethdev.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index cf5a2ec..79c6cc4 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -242,6 +242,7 @@ static void dpaa_eth_dev_info(struct rte_eth_dev *dev,
dev_info->max_tx_queues = dpaa_intf->nb_tx_queues;
dev_info->min_rx_bufsize = DPAA_MIN_RX_BUF_SIZE;
dev_info->max_rx_pktlen = DPAA_MAX_RX_PKT_LEN;
+   dev_info->max_burst_size = DPAA_MAX_BURST_SIZE;
dev_info->max_mac_addrs = DPAA_MAX_MAC_FILTER;
dev_info->max_hash_mac_addrs = 0;
dev_info->max_vfs = 0;
diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h
index 5457d61..0400dce 100644
--- a/drivers/net/dpaa/dpaa_ethdev.h
+++ b/drivers/net/dpaa/dpaa_ethdev.h
@@ -64,6 +64,7 @@
 
 #define DPAA_MIN_RX_BUF_SIZE 512
 #define DPAA_MAX_RX_PKT_LEN  10240
+#define DPAA_MAX_BURST_SIZE16
 
 /* RX queue tail drop threshold
  * currently considering 32 KB packets.
-- 
2.7.4



[dpdk-dev] [PATCH 2/4] examples/l3fwd-power: fix the timer for any platform freq

2017-12-12 Thread Nikhil Agarwal
The code assumes that the platform frequency is 2GHz.
This patch add support for dynamically detecting platform frequence.

Fixes: d7937e2e3d12 ("power: initial import")
Cc: sta...@dpdk.org

Signed-off-by: Nikhil Agarwal 
---
 examples/l3fwd-power/main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index d335b0d..50c3702 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -79,8 +79,6 @@
 
 #define MIN_ZERO_POLL_COUNT 10
 
-/* around 100ms at 2 Ghz */
-#define TIMER_RESOLUTION_CYCLES   2ULL
 /* 100 ms interval */
 #define TIMER_NUMBER_PER_SECOND   10
 /* 10 us */
@@ -875,7 +873,7 @@ main_loop(__attribute__((unused)) void *dummy)
 {
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
unsigned lcore_id;
-   uint64_t prev_tsc, diff_tsc, cur_tsc;
+   uint64_t prev_tsc, diff_tsc, cur_tsc, tim_res_tsc, hz;
uint64_t prev_tsc_power = 0, cur_tsc_power, diff_tsc_power;
int i, j, nb_rx;
uint8_t queueid;
@@ -890,6 +888,8 @@ main_loop(__attribute__((unused)) void *dummy)
const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S 
* BURST_TX_DRAIN_US;
 
prev_tsc = 0;
+   hz = rte_get_timer_hz();
+   tim_res_tsc = hz/TIMER_NUMBER_PER_SECOND;
 
lcore_id = rte_lcore_id();
qconf = &lcore_conf[lcore_id];
@@ -935,7 +935,7 @@ main_loop(__attribute__((unused)) void *dummy)
}
 
diff_tsc_power = cur_tsc_power - prev_tsc_power;
-   if (diff_tsc_power > TIMER_RESOLUTION_CYCLES) {
+   if (diff_tsc_power > tim_res_tsc) {
rte_timer_manage();
prev_tsc_power = cur_tsc_power;
}
-- 
2.7.4



[dpdk-dev] [PATCH 1/4] examples/l3fwd-power: fix non Rx intr supported platform

2017-12-12 Thread Nikhil Agarwal
This existing code cause the platform to start receiving packet
immediately irrespective of interrupts available or not.
If the platform does not support Rx interrupt, it shall not start
receiving packets immediately. It shall let the timer management work.

Fixes: aee3bc79cc34 ("examples/l3fwd-power: enable one-shot Rx interrupt and 
polling switch")
Cc: sta...@dpdk.org
Cc: Danny Zhou 
Cc: Cunming Liang 

Signed-off-by: Nikhil Agarwal 
---
 examples/l3fwd-power/main.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 0a4ed14..d335b0d 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -1051,9 +1051,11 @@ main_loop(__attribute__((unused)) void *dummy)
turn_on_intr(qconf);
sleep_until_rx_interrupt(
qconf->n_rx_queue);
+   /**
+* start receiving packets immediately
+*/
+   goto start_rx;
}
-   /* start receiving packets immediately */
-   goto start_rx;
}
stats[lcore_id].sleep_time += lcore_idle_hint;
}
-- 
2.7.4



[dpdk-dev] [PATCH 4/4] examples/l3fwd-power: disable Lsc interrupts

2017-12-12 Thread Nikhil Agarwal
This application does not need Link Status Interrupt.
It will cause failure for the platforms not supporting LSC.

Signed-off-by: Nikhil Agarwal 
---
 examples/l3fwd-power/main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 4ddd04c..d80f663 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -229,7 +229,6 @@ static struct rte_eth_conf port_conf = {
.mq_mode = ETH_MQ_TX_NONE,
},
.intr_conf = {
-   .lsc = 1,
.rxq = 1,
},
 };
-- 
2.7.4



[dpdk-dev] [PATCH 3/4] examples/l3fwd-power: replace desc done with Rx queue count

2017-12-12 Thread Nikhil Agarwal
HW queue based platforms may not support descriptor done API.
This patch changes the usages to rx_queue_count API, which
is more generic.

Signed-off-by: Nikhil Agarwal 
---
 examples/l3fwd-power/main.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 50c3702..4ddd04c 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -755,6 +755,7 @@ power_freq_scaleup_heuristic(unsigned lcore_id,
 uint16_t port_id,
 uint16_t queue_id)
 {
+   uint32_t rxq_count = rte_eth_rx_queue_count(port_id, queue_id);
 /**
  * HW Rx queue size is 128 by default, Rx burst read at maximum 32 entries
  * per iteration
@@ -766,15 +767,12 @@ power_freq_scaleup_heuristic(unsigned lcore_id,
 #define FREQ_UP_TREND2_ACC   100
 #define FREQ_UP_THRESHOLD1
 
-   if (likely(rte_eth_rx_descriptor_done(port_id, queue_id,
-   FREQ_GEAR3_RX_PACKET_THRESHOLD) > 0)) {
+   if (likely(rxq_count > FREQ_GEAR3_RX_PACKET_THRESHOLD)) {
stats[lcore_id].trend = 0;
return FREQ_HIGHEST;
-   } else if (likely(rte_eth_rx_descriptor_done(port_id, queue_id,
-   FREQ_GEAR2_RX_PACKET_THRESHOLD) > 0))
+   } else if (likely(rxq_count > FREQ_GEAR2_RX_PACKET_THRESHOLD))
stats[lcore_id].trend += FREQ_UP_TREND2_ACC;
-   else if (likely(rte_eth_rx_descriptor_done(port_id, queue_id,
-   FREQ_GEAR1_RX_PACKET_THRESHOLD) > 0))
+   else if (likely(rxq_count > FREQ_GEAR1_RX_PACKET_THRESHOLD))
stats[lcore_id].trend += FREQ_UP_TREND1_ACC;
 
if (likely(stats[lcore_id].trend > FREQ_UP_THRESHOLD)) {
-- 
2.7.4



Re: [dpdk-dev] [PATCH 1/3] ethdev: add max burst size to device info

2017-12-12 Thread Matan Azrad
Hi Nikhil

> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Nikhil Agarwal
> Sent: Tuesday, December 12, 2017 12:05 PM
> To: dev@dpdk.org
> Cc: david.h...@intel.com; nikhil.agar...@nxp.com;
> hemant.agra...@nxp.com; ferruh.yi...@intel.com
> Subject: [dpdk-dev] [PATCH 1/3] ethdev: add max burst size to device info
> 
> Currently, if the  rte_eth_rx_burst() function returns a value less than
> *nb_pkts*, the application will assume that no more packets are present.
> 
> Some of the hw queue based hardware can only support smaller burst for RX
> and TX and thus break the expectation of the rx_burst API.
>

Doesn't such like devices PMDs should try to retrieve multiple HW burst to 
adjust the asked received  packet number?
 
> This patch adds support to provide the maximum burst size that can be
> supported by a given PMD. The dev_info is being memset to '0' in
> rte_ethdev library. The value of '0' indicates that any value for burst size 
> can
> be supported i.e. no change for existing PMDs.
> 
> The application can now use the lowest available max_burst_size value for
> rte_eth_rx_burst.
> 

If you are talking about performance, maybe the right field to expose is 
something like "perf_burst_size" or "preferred_burst_size".
I also suggest to expose different fields for RX and for TX.
Maybe the rte_eth_rx\tx_burst() descriptions should be updated. 

Thanks
Matan.

> Signed-off-by: Nikhil Agarwal 
> ---
>  lib/librte_ether/rte_ethdev.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index 341c2d6..3ab6f02 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -1047,6 +1047,7 @@ struct rte_eth_dev_info {
>   /** Configured number of rx/tx queues */
>   uint16_t nb_rx_queues; /**< Number of RX queues. */
>   uint16_t nb_tx_queues; /**< Number of TX queues. */
> + uint16_t max_burst_size; /**< MAX burst size, 0 for no limit. */
>  };
> 
>  /**
> --
> 2.7.4



Re: [dpdk-dev] [PATCH 12/12] doc: update vhost crypto documentation

2017-12-12 Thread Kovacevic, Marko


> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Fan Zhang
> Sent: Monday, November 27, 2017 8:01 PM
> To: dev@dpdk.org
> Cc: Zhang, Roy Fan ; y...@fridaylinux.org;
> maxime.coque...@redhat.com; Bie, Tiwei 
> Subject: [dpdk-dev] [PATCH 12/12] doc: update vhost crypto documentation
> 
> Signed-off-by: Fan Zhang 
> ---
>  doc/guides/prog_guide/vhost_lib.rst   | 16 ++
>  doc/guides/rel_notes/release_18_02.rst|  7 +++
>  doc/guides/sample_app_ug/index.rst|  1 +
>  doc/guides/sample_app_ug/vhost_crypto.rst | 95

Please remove the whitespace at the EOF from the 
doc/guides/sample_app_ug/vhost_crypto.rst
Otherwise everything seems ok to me.

Acked-by: Marko Kovacevic 


Re: [dpdk-dev] [PATCH 1/3] ethdev: add max burst size to device info

2017-12-12 Thread Ananyev, Konstantin


> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Matan Azrad
> Sent: Tuesday, December 12, 2017 10:46 AM
> To: Nikhil Agarwal ; dev@dpdk.org
> Cc: Hunt, David ; nikhil.agar...@nxp.com; 
> hemant.agra...@nxp.com; Yigit, Ferruh 
> Subject: Re: [dpdk-dev] [PATCH 1/3] ethdev: add max burst size to device info
> 
> Hi Nikhil
> 
> > -Original Message-
> > From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Nikhil Agarwal
> > Sent: Tuesday, December 12, 2017 12:05 PM
> > To: dev@dpdk.org
> > Cc: david.h...@intel.com; nikhil.agar...@nxp.com;
> > hemant.agra...@nxp.com; ferruh.yi...@intel.com
> > Subject: [dpdk-dev] [PATCH 1/3] ethdev: add max burst size to device info
> >
> > Currently, if the  rte_eth_rx_burst() function returns a value less than
> > *nb_pkts*, the application will assume that no more packets are present.
> >
> > Some of the hw queue based hardware can only support smaller burst for RX
> > and TX and thus break the expectation of the rx_burst API.
> >
> 
> Doesn't such like devices PMDs should try to retrieve multiple HW burst to 
> adjust the asked received  packet number?

Same thought here...
Can't that limitation be hidden inside PMD by calling HW burst multiple times? 
Also if I am not mistaken - it would increase size of struct rte_eth_dev_info, 
right?
If so, then it means ABI breakage.
Konstantin

> 
> > This patch adds support to provide the maximum burst size that can be
> > supported by a given PMD. The dev_info is being memset to '0' in
> > rte_ethdev library. The value of '0' indicates that any value for burst 
> > size can
> > be supported i.e. no change for existing PMDs.
> >
> > The application can now use the lowest available max_burst_size value for
> > rte_eth_rx_burst.
> >
> 
> If you are talking about performance, maybe the right field to expose is 
> something like "perf_burst_size" or "preferred_burst_size".
> I also suggest to expose different fields for RX and for TX.
> Maybe the rte_eth_rx\tx_burst() descriptions should be updated.
> 
> Thanks
> Matan.
> 
> > Signed-off-by: Nikhil Agarwal 
> > ---
> >  lib/librte_ether/rte_ethdev.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> > index 341c2d6..3ab6f02 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -1047,6 +1047,7 @@ struct rte_eth_dev_info {
> > /** Configured number of rx/tx queues */
> > uint16_t nb_rx_queues; /**< Number of RX queues. */
> > uint16_t nb_tx_queues; /**< Number of TX queues. */
> > +   uint16_t max_burst_size; /**< MAX burst size, 0 for no limit. */
> >  };
> >
> >  /**
> > --
> > 2.7.4



Re: [dpdk-dev] [RFC] ethdev: add administrative information in per-port info

2017-12-12 Thread Olivier MATZ
Hi Andrew,

On Wed, Nov 15, 2017 at 12:09:24PM +0300, Andrew Rybchenko wrote:
> On 09/08/2017 12:21 PM, Ivan Boule wrote:
> > To help administrative tasks on DPDK ports, add in the data structure
> > rte_eth_dev_info the following per-port information to be supplied
> > by the dev_infos_get() function exported by a Poll Mode Driver:
> > 
> > - the set of supported link modes,
> > - the set of advertised link modes,
> > - the type of port connector,
> > - autonegotiation enabled or not.
> 
> Sorry for late response. I've lost it from my view until today's discussion
> of
> deprecation notice.

Sorry also for my late answer, and thank you for your comments.

> Just for my understanding. I always considered dev_info as place for
> more or less stable information like capabilities and physical restrictions.
> Port connector perfectly fits it, but advertised link modes and autoneg
> status are more dynamic. May be it is a better way to have dedicated API?
> Just would like to raise discussion and understand why finally one or
> another way will be chosen.

Yes, you are right. I think we can find some exceptions:

- nb_rx_queues/nb_tx_queues return the current number of configured queues
- the speed capabilities may depend on the SFP, which can be hot-plugged
- with a failsafe driver, the capabilities/limits depend on the list of
  sub-devices
- maybe the offload capabilities on a virtio device could depend on the
  peer configuration.

But, yes, a new API is maybe better to avoid adding another exception.
Something like rte_eth_media_get() ?


> Also see note below about connectors.
> 
> > Set new administrative fields to a default value in rte_eth_dev_info_get()
> > before invoking the dev_infos_get() function exported by a PMD, if any.
> > 
> > Once this API change is accepted, the dev_infos_get() function of PMDs
> > will be updated accordingly to set these new fields, along with the
> > port_infos_display() function of the testpmd to display them.
> > 
> > Signed-off-by: Ivan Boule 
> > ---
> >   lib/librte_ether/rte_ethdev.c |   1 +
> >   lib/librte_ether/rte_ethdev.h | 112 
> > ++
> >   2 files changed, 113 insertions(+)
> > 
> > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> > index 0597641..4ca51e1 100644
> > --- a/lib/librte_ether/rte_ethdev.c
> > +++ b/lib/librte_ether/rte_ethdev.c
> > @@ -1897,6 +1897,7 @@ rte_eth_dev_info_get(uint8_t port_id, struct 
> > rte_eth_dev_info *dev_info)
> > memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
> > dev_info->rx_desc_lim = lim;
> > dev_info->tx_desc_lim = lim;
> > +   dev_info->connector = RTE_ETH_CONNECTOR_OTHER;
> > RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_infos_get);
> > (*dev->dev_ops->dev_infos_get)(dev, dev_info);
> > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> > index 0adf327..ac49380 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -935,6 +935,113 @@ struct rte_pci_device;
> >   /**
> >* Ethernet device information
> >*/
> > +
> > +/* Types of port connector. */
> > +#define RTE_ETH_CONNECTOR_TP0x00 /**< Twisted Pair */
> > +#define RTE_ETH_CONNECTOR_AUI   0x01 /**< Attachment Unit Interface */
> > +#define RTE_ETH_CONNECTOR_MII   0x02 /**< Media-Independent Interface 
> > */
> > +#define RTE_ETH_CONNECTOR_FIBRE 0x03 /**< Fiber */
> > +#define RTE_ETH_CONNECTOR_DA0x05 /**< Direct Attach */
> 
> I thought that examples of connectors are rather RG45, SFP, SFP+, QSFP+,
> SFP28, QSFP28.
> Media could be twisted pair, fibre, direct attach etc.

The types of connectors are derivated from Linux ethtool.
But thinking at it, directly copying the defines would cause licensing
issues since ethtool is GPL.

Unfortunatly, I don't know that much about the different types of
connectors and media. I found some inputs on the wikipedia page
( https://en.wikipedia.org/wiki/Ethernet_physical_layer ), but
any additional input is welcome :)


> > +#define RTE_ETH_CONNECTOR_NONE  0xef
> > +#define RTE_ETH_CONNECTOR_OTHER 0xff
> > +
> > +/* Link modes. */
> > +#define RTE_ETH_LINK_MODE_10baseT_Half_BIT0
> > +#define RTE_ETH_LINK_MODE_10baseT_Full_BIT1
> > +#define RTE_ETH_LINK_MODE_100baseT_Half_BIT   2
> > +#define RTE_ETH_LINK_MODE_100baseT_Full_BIT   3
> > +#define RTE_ETH_LINK_MODE_1000baseT_Half_BIT  4
> > +#define RTE_ETH_LINK_MODE_1000baseT_Full_BIT  5
> > +#define RTE_ETH_LINK_MODE_Autoneg_BIT 6
> > +#define RTE_ETH_LINK_MODE_TP_BIT  7
> > +#define RTE_ETH_LINK_MODE_AUI_BIT 8
> > +#define RTE_ETH_LINK_MODE_MII_BIT 9
> > +#define RTE_ETH_LINK_MODE_FIBRE_BIT  10
> > +#define RTE_ETH_LINK_MODE_BNC_BIT11
> > +#define RTE_ETH_LINK_MODE_1baseT_Full_BIT12
> > +#define RTE_ETH_LINK_MODE_Pa

Re: [dpdk-dev] [PATCH v5] examples/ipsec-secgw: fix usage of incorrect port

2017-12-12 Thread Radu Nicolau



On 12/12/2017 8:32 AM, Anoob Joseph wrote:

When security offload is enabled, the packet should be forwarded on the
port configured in the SA. Security session will be configured on that
port only, and sending the packet on other ports could result in
unencrypted packets being sent out.

This would have performance improvements too, as the per packet LPM
lookup would be avoided for IPsec packets, in inline mode.

Fixes: ec17993a145a ("examples/ipsec-secgw: support security offload")

Signed-off-by: Anoob Joseph 
Acked-by: Akhil Goyal 

Acked-by: Radu Nicolau 


Re: [dpdk-dev] [PATCH 02/11] crypto/ccp: add support for AMD CCP crypto PMD

2017-12-12 Thread Kumar, Ravi1
>Hi Ravi,
>
>> -Original Message-
>> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Ravi Kumar
>> Sent: Thursday, November 30, 2017 1:12 PM
>> To: dev@dpdk.org
>> Subject: [dpdk-dev] [PATCH 02/11] crypto/ccp: add support for AMD CCP 
>> crypto PMD
>> 
>
>As I said in the another patch, you should add a commit message for complex 
>patches like this one.
>Another thing that would be useful for improving the readability of the 
>patchset and therefore, make a review easier, is to split a long patch in 
>smaller patches.
>
>From what I have seen, you have some patches where you are adding support for 
>CMAC and SHA3 algorithms. I suggest to do the same for the other algorithms 
>that this PMD supports.
>So, the first patch would have the skeleton of the PMD, and then you can have 
>a separate patch per algorithm.
>Well, not necessarily, a patch per algorithm, but per subset of algorithms.
>I would propose one for AES-CBC/ECB/CTR, one for 3DES-CBC, one for AES-GCM and 
>another one for SHA-x algorithms.
>
>Thanks,
>Pablo
>
Hi Pablo,

Thanks for all the comments. We are working on them.

Regards,
Ravi


[dpdk-dev] [PATCH v2 02/39] examples/l2fwd-crypto: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/l2fwd-crypto/main.c | 37 +
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index d4e1682..81d2957 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -235,19 +235,17 @@ struct lcore_queue_conf {
 
 struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE];
 
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
.rxmode = {
.mq_mode = ETH_MQ_RX_NONE,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -2356,6 +2354,9 @@ struct l2fwd_crypto_statistics {
 
for (last_portid = 0, portid = 0; portid < nb_ports; portid++) {
int retval;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
 
/* Skip ports that are not enabled */
if ((options->portmask & (1 << portid)) == 0)
@@ -2364,6 +2365,21 @@ struct l2fwd_crypto_statistics {
/* init port */
printf("Initializing port %u... ", portid);
fflush(stdout);
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
retval = rte_eth_dev_configure(portid, 1, 1, &port_conf);
if (retval < 0) {
printf("Cannot configure device: err=%d, port=%u\n",
@@ -2381,9 +2397,11 @@ struct l2fwd_crypto_statistics {
 
/* init one RX queue */
fflush(stdout);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
retval = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
 rte_eth_dev_socket_id(portid),
-NULL, l2fwd_pktmbuf_pool);
+&rxq_conf, l2fwd_pktmbuf_pool);
if (retval < 0) {
printf("rte_eth_rx_queue_setup:err=%d, port=%u\n",
retval, portid);
@@ -2392,9 +2410,12 @@ struct l2fwd_crypto_statistics {
 
/* init one TX queue on each port */
fflush(stdout);
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
retval = rte_eth_tx_queue_setup(portid, 0, nb_txd,
rte_eth_dev_socket_id(portid),
-   NULL);
+   &txq_conf);
if (retval < 0) {
printf("rte_eth_tx_queue_setup:err=%d, port=%u\n",
retval, portid);
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 00/39] convert examples to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
This series is to convert DPDK examples to the new offloads API [1].

on v2:
 - Add DEV_TX_OFFLOAD_MBUF_FAST_FREE offload of entitled examples.
 - Instead of masking the un-supported offloads print a warning and let
   the PMD to fail the configuration.

[1] http://dpdk.org/ml/archives/dev/2017-October/077329.html

Shahaf Shuler (39):
  examples/l2fwd: convert to new ethdev offloads API
  examples/l2fwd-crypto: convert to new ethdev offloads API
  examples/l2fwd-jobstats: convert to new ethdev offloads API
  examples/l2fwd-keepalive: convert to new ethdev offloads API
  examples/l3fwd: move to ethdev offloads API
  examples/l3fwd-acl: convert to new ethdev offloads API
  examples/l3fwd-power: convert to new ethdev offloads API
  examples/l3fwd-vf: convert to new ethdev offloads API
  examples/bond: convert to new ethdev offloads API
  examples/exception_path: convert to new ethdev offloads API
  examples/kni: convert to new ethdev offloads API
  examples/ip_fragmentation: convert to new offloads API
  examples/ip_pipeline: convert to new ethdev offloads API
  examples/ip_reassembly: convert to new ethdev offloads API
  examples/ipsec-secgw: convert to new ethdev offloads API
  examples/ipv4_multicast: convert to new ethdev offloads API
  examples/link_status_interrupt: convert to new offloads API
  examples/load_balancer: convert to new ethdev offloads API
  examples/multi_process: convert to new ethdev offloads API
  examples/netmap_compat: convert to new ethdev offloads API
  examples/performance-thread: convert to new offloads API
  examples/qos_meter: convert to new ethdev offloads API
  examples/qos_sched: convert to new ethdev offloads API
  examples/quota_watermark: convert to new ethdev offloads API
  examples/tep_termination: convert to new ethdev offloads API
  examples/vhost: convert to new ethdev offloads API
  examples/vmdq: convert to new ethdev offloads API
  examples/vmdq_dcb: convert to new ethdev offloads API
  examples/vm_power_manager: convert to new offloads API
  examples/distributor: convert to new ethdev offloads API
  examples/ethtool: convert to new ethdev offloads API
  examples/eventdev_pipeline: convert to new offloads API
  examples/flow_classify: convert to new ethdev offloads API
  examples/flow_filtering: convert to new ethdev offloads API
  examples/packet_ordering: convert to new ethdev offloads API
  examples/ptpclient: convert to new ethdev offloads API
  examples/rxtx_callbacks: convert to new ethdev offloads API
  examples/server_node_efd: convert to new ethdev offloads API
  examples/skeleton: convert to new ethdev offloads API

 examples/bond/main.c| 65 ---
 examples/distributor/main.c | 25 +++-
 examples/ethtool/ethtool-app/main.c |  7 ++-
 examples/eventdev_pipeline_sw_pmd/main.c| 29 -
 examples/exception_path/main.c  | 37 ---
 examples/flow_classify/flow_classify.c  | 31 -
 examples/flow_filtering/main.c  | 26 
 examples/ip_fragmentation/main.c| 35 ---
 examples/ip_pipeline/config_parse.c | 14 ++---
 examples/ip_pipeline/init.c | 26 ++--
 examples/ip_reassembly/main.c   | 35 ---
 examples/ipsec-secgw/ipsec-secgw.c  | 26 +++-
 examples/ipv4_multicast/main.c  | 33 +++---
 examples/kni/main.c | 66 +---
 examples/l2fwd-crypto/main.c| 37 ---
 examples/l2fwd-jobstats/main.c  | 38 ---
 examples/l2fwd-keepalive/main.c | 38 ---
 examples/l2fwd/main.c   | 37 ---
 examples/l3fwd-acl/main.c   | 40 +---
 examples/l3fwd-power/main.c | 41 +---
 examples/l3fwd-vf/main.c| 37 ---
 examples/l3fwd/main.c   | 40 +---
 examples/link_status_interrupt/main.c   | 37 ---
 examples/load_balancer/init.c   | 36 ---
 examples/multi_process/l2fwd_fork/main.c| 35 ---
 examples/multi_process/symmetric_mp/main.c  | 34 +++---
 examples/netmap_compat/bridge/bridge.c  |  8 +--
 examples/netmap_compat/lib/compat_netmap.c  | 27 +++-
 examples/packet_ordering/main.c | 32 +-
 examples/performance-thread/l3fwd-thread/main.c | 41 +---
 examples/ptpclient/ptpclient.c  | 28 -
 examples/qos_meter/main.c   | 61 +++---
 examples/qos_sched/init.c   | 30 ++---
 examples/quota_watermark/qw/init.c  | 37 ---
 examples/rxtx_callbacks/main.c  | 31 -
 examples/server_node_efd/server/init.c  | 33 --
 examples/skeleton/basicfwd.c  

[dpdk-dev] [PATCH v2 01/39] examples/l2fwd: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/l2fwd/main.c | 37 +
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index e89e2e1..e25b107 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -110,17 +110,15 @@ struct lcore_queue_conf {
 
 static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS];
 
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
.rxmode = {
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -649,6 +647,9 @@ enum {
 
/* Initialise each port */
for (portid = 0; portid < nb_ports; portid++) {
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
+
/* skip ports that are not enabled */
if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
printf("Skipping disabled port %u\n", portid);
@@ -658,6 +659,21 @@ enum {
/* init port */
printf("Initializing port %u... ", portid);
fflush(stdout);
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Cannot configure device: 
err=%d, port=%u\n",
@@ -674,9 +690,11 @@ enum {
 
/* init one RX queue */
fflush(stdout);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
 rte_eth_dev_socket_id(portid),
-NULL,
+&rxq_conf,
 l2fwd_pktmbuf_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, 
port=%u\n",
@@ -684,9 +702,12 @@ enum {
 
/* init one TX queue on each port */
fflush(stdout);
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
rte_eth_dev_socket_id(portid),
-   NULL);
+   &txq_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup:err=%d, 
port=%u\n",
ret, portid);
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 03/39] examples/l2fwd-jobstats: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/l2fwd-jobstats/main.c | 38 +
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index 485370d..eb035ef 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -116,17 +116,15 @@ struct lcore_queue_conf {
 
 struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS];
 
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
.rxmode = {
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -866,6 +864,10 @@ struct l2fwd_port_statistics {
 
/* Initialise each port */
for (portid = 0; portid < nb_ports; portid++) {
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
+
/* skip ports that are not enabled */
if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
printf("Skipping disabled port %u\n", portid);
@@ -875,6 +877,21 @@ struct l2fwd_port_statistics {
/* init port */
printf("Initializing port %u... ", portid);
fflush(stdout);
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Cannot configure device: 
err=%d, port=%u\n",
@@ -891,19 +908,24 @@ struct l2fwd_port_statistics {
 
/* init one RX queue */
fflush(stdout);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
 rte_eth_dev_socket_id(portid),
-NULL,
+&rxq_conf,
 l2fwd_pktmbuf_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, 
port=%u\n",
  ret, portid);
 
/* init one TX queue on each port */
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
fflush(stdout);
ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
rte_eth_dev_socket_id(portid),
-   NULL);
+   &txq_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE,
"rte_eth_tx_queue_setup:err=%d, port=%u\n",
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 05/39] examples/l3fwd: move to ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/l3fwd/main.c | 40 ++--
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 6229568..3bdf4d5 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -149,11 +149,9 @@ struct lcore_params {
.mq_mode = ETH_MQ_RX_RSS,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 1, /**< IP checksum offload enabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
+DEV_RX_OFFLOAD_CHECKSUM),
},
.rx_adv_conf = {
.rss_conf = {
@@ -163,6 +161,7 @@ struct lcore_params {
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -612,7 +611,8 @@ enum {
};
 
printf("%s\n", str8);
-   port_conf.rxmode.jumbo_frame = 1;
+   port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+   port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
 
/*
 * if no max-pkt-len set, use the default
@@ -908,6 +908,22 @@ enum {
n_tx_queue = MAX_TX_QUEUE_PER_PORT;
printf("Creating queues: nb_rxq=%d nb_txq=%u... ",
nb_rx_queue, (unsigned)n_tx_queue );
+
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, nb_rx_queue,
(uint16_t)n_tx_queue, &port_conf);
if (ret < 0)
@@ -955,10 +971,9 @@ enum {
printf("txq=%u,%d,%d ", lcore_id, queueid, socketid);
fflush(stdout);
 
-   rte_eth_dev_info_get(portid, &dev_info);
txconf = &dev_info.default_txconf;
-   if (port_conf.rxmode.jumbo_frame)
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
 socketid, txconf);
if (ret < 0)
@@ -984,6 +999,8 @@ enum {
fflush(stdout);
/* init RX queues */
for(queue = 0; queue < qconf->n_rx_queue; ++queue) {
+   struct rte_eth_rxconf rxq_conf;
+
portid = qconf->rx_queue_list[queue].port_id;
queueid = qconf->rx_queue_list[queue].queue_id;
 
@@ -996,9 +1013,12 @@ enum {
printf("rxq=%d,%d,%d ", portid, queueid, socketid);
fflush(stdout);
 
+   rte_eth_dev_info_get(portid, &dev_info);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd,
socketid,
-   NULL,
+   &rxq_conf,
pktmbuf_pool[socketid]);
if (ret < 0)
rte_exit(EXIT_FAILURE,
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 07/39] examples/l3fwd-power: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
Acked-by: David Hunt 
---
 examples/l3fwd-power/main.c | 41 ++--
 1 file changed, 31 insertions(+), 10 deletions(-)

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 0a4ed14..10c6f1b 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -215,11 +215,9 @@ struct lcore_params {
.mq_mode= ETH_MQ_RX_RSS,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 1, /**< IP checksum offload enabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
+DEV_RX_OFFLOAD_CHECKSUM),
},
.rx_adv_conf = {
.rss_conf = {
@@ -229,6 +227,7 @@ struct lcore_params {
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
.intr_conf = {
.lsc = 1,
@@ -1317,7 +1316,10 @@ static int parse_max_pkt_len(const char *pktlen)
0, 0};
 
printf("jumbo frame is enabled \n");
-   port_conf.rxmode.jumbo_frame = 1;
+   port_conf.rxmode.offloads |=
+   DEV_RX_OFFLOAD_JUMBO_FRAME;
+   port_conf.txmode.offloads |=
+   DEV_TX_OFFLOAD_MULTI_SEGS;
 
/**
 * if no max-pkt-len set, use the default value
@@ -1718,6 +1720,21 @@ static int check_ptype(uint16_t portid)
/* If number of Rx queue is 0, no need to enable Rx interrupt */
if (nb_rx_queue == 0)
port_conf.intr_conf.rxq = 0;
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, nb_rx_queue,
(uint16_t)n_tx_queue, &port_conf);
/* Revert to original value */
@@ -1776,10 +1793,9 @@ static int check_ptype(uint16_t portid)
printf("txq=%u,%d,%d ", lcore_id, queueid, socketid);
fflush(stdout);
 
-   rte_eth_dev_info_get(portid, &dev_info);
txconf = &dev_info.default_txconf;
-   if (port_conf.rxmode.jumbo_frame)
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
 socketid, txconf);
if (ret < 0)
@@ -1819,6 +1835,8 @@ static int check_ptype(uint16_t portid)
fflush(stdout);
/* init RX queues */
for(queue = 0; queue < qconf->n_rx_queue; ++queue) {
+   struct rte_eth_rxconf rxq_conf;
+
portid = qconf->rx_queue_list[queue].port_id;
queueid = qconf->rx_queue_list[queue].queue_id;
 
@@ -1831,8 +1849,11 @@ static int check_ptype(uint16_t portid)
printf("rxq=%d,%d,%d ", portid, queueid, socketid);
fflush(stdout);
 
+   rte_eth_dev_info_get(portid, &dev_info);
+   rxq_conf = dev_info.default_rxconf;
+ 

[dpdk-dev] [PATCH v2 06/39] examples/l3fwd-acl: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
Acked-by: Konstantin Ananyev 
---
 examples/l3fwd-acl/main.c | 40 +++-
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index e50b1a1..e13b1d9 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -156,11 +156,9 @@ struct lcore_params {
.mq_mode= ETH_MQ_RX_RSS,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 1, /**< IP checksum offload enabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
+DEV_RX_OFFLOAD_CHECKSUM),
},
.rx_adv_conf = {
.rss_conf = {
@@ -171,6 +169,7 @@ struct lcore_params {
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -1727,7 +1726,10 @@ struct lcore_conf {
};
 
printf("jumbo frame is enabled\n");
-   port_conf.rxmode.jumbo_frame = 1;
+   port_conf.rxmode.offloads |=
+   DEV_RX_OFFLOAD_JUMBO_FRAME;
+   port_conf.txmode.offloads |=
+   DEV_TX_OFFLOAD_MULTI_SEGS;
 
/*
 * if no max-pkt-len set, then use the
@@ -1948,6 +1950,21 @@ struct lcore_conf {
n_tx_queue = MAX_TX_QUEUE_PER_PORT;
printf("Creating queues: nb_rxq=%d nb_txq=%u... ",
nb_rx_queue, (unsigned)n_tx_queue);
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, nb_rx_queue,
(uint16_t)n_tx_queue, &port_conf);
if (ret < 0)
@@ -2004,8 +2021,8 @@ struct lcore_conf {
 
rte_eth_dev_info_get(portid, &dev_info);
txconf = &dev_info.default_txconf;
-   if (port_conf.rxmode.jumbo_frame)
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
 socketid, txconf);
if (ret < 0)
@@ -2031,6 +2048,8 @@ struct lcore_conf {
fflush(stdout);
/* init RX queues */
for (queue = 0; queue < qconf->n_rx_queue; ++queue) {
+   struct rte_eth_rxconf rxq_conf;
+
portid = qconf->rx_queue_list[queue].port_id;
queueid = qconf->rx_queue_list[queue].queue_id;
 
@@ -2043,8 +2062,11 @@ struct lcore_conf {
printf("rxq=%d,%d,%d ", portid, queueid, socketid);
fflush(stdout);
 
+   rte_eth_dev_info_get(portid, &dev_info);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd,
-   socketid, NULL,
+   socketid, &rxq_conf,
pktmbuf_pool[socketid]);
  

[dpdk-dev] [PATCH v2 04/39] examples/l2fwd-keepalive: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/l2fwd-keepalive/main.c | 38 
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index 358ca5e..a60d3e9 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -107,17 +107,15 @@ struct lcore_queue_conf {
 
 struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS];
 
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
.rxmode = {
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -658,6 +656,10 @@ static void handle_sigterm(__rte_unused int value)
 
/* Initialise each port */
for (portid = 0; portid < nb_ports; portid++) {
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
+
/* skip ports that are not enabled */
if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
printf("Skipping disabled port %u\n", portid);
@@ -667,6 +669,21 @@ static void handle_sigterm(__rte_unused int value)
/* init port */
printf("Initializing port %u... ", portid);
fflush(stdout);
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE,
@@ -684,9 +701,11 @@ static void handle_sigterm(__rte_unused int value)
 
/* init one RX queue */
fflush(stdout);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
 rte_eth_dev_socket_id(portid),
-NULL,
+&rxq_conf,
 l2fwd_pktmbuf_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE,
@@ -695,9 +714,12 @@ static void handle_sigterm(__rte_unused int value)
 
/* init one TX queue on each port */
fflush(stdout);
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
rte_eth_dev_socket_id(portid),
-   NULL);
+   &txq_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE,
"rte_eth_tx_queue_setup:err=%d, port=%u\n",
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 08/39] examples/l3fwd-vf: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/l3fwd-vf/main.c | 37 -
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c
index 6ef89fc..04aaa13 100644
--- a/examples/l3fwd-vf/main.c
+++ b/examples/l3fwd-vf/main.c
@@ -190,11 +190,9 @@ struct lcore_params {
.mq_mode= ETH_MQ_RX_RSS,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 1, /**< IP checksum offload enabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
+DEV_RX_OFFLOAD_CHECKSUM),
},
.rx_adv_conf = {
.rss_conf = {
@@ -204,6 +202,7 @@ struct lcore_params {
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -1006,6 +1005,22 @@ struct lcore_conf {
 
printf("Creating queues: nb_rxq=%d nb_txq=%u... ",
nb_rx_queue, (unsigned)1 );
+
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, nb_rx_queue, n_tx_queue, 
&port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Cannot configure device: 
err=%d, port=%d\n",
@@ -1032,10 +1047,9 @@ struct lcore_conf {
printf("txq=%d,%d,%d ", portid, 0, socketid);
fflush(stdout);
 
-   rte_eth_dev_info_get(portid, &dev_info);
txconf = &dev_info.default_txconf;
-   if (port_conf.rxmode.jumbo_frame)
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
 socketid, txconf);
if (ret < 0)
@@ -1046,6 +1060,8 @@ struct lcore_conf {
}
 
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
+   struct rte_eth_rxconf rxq_conf;
+
if (rte_lcore_is_enabled(lcore_id) == 0)
continue;
qconf = &lcore_conf[lcore_id];
@@ -1066,8 +1082,11 @@ struct lcore_conf {
printf("rxq=%d,%d,%d ", portid, queueid, socketid);
fflush(stdout);
 
+   rte_eth_dev_info_get(portid, &dev_info);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd,
-   socketid, NULL,
+   socketid, &rxq_conf,
pktmbuf_pool[socketid]);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup: 
err=%d,"
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 09/39] examples/bond: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
Reviewed-by: Radu Nicolau 
---
 examples/bond/main.c | 65 +++
 1 file changed, 55 insertions(+), 10 deletions(-)

diff --git a/examples/bond/main.c b/examples/bond/main.c
index 8e3b1f3..d0050b3 100644
--- a/examples/bond/main.c
+++ b/examples/bond/main.c
@@ -151,11 +151,8 @@
.mq_mode = ETH_MQ_RX_NONE,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload enabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.rx_adv_conf = {
.rss_conf = {
@@ -165,6 +162,7 @@
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -174,10 +172,28 @@
int retval;
uint16_t nb_rxd = RTE_RX_DESC_DEFAULT;
uint16_t nb_txd = RTE_TX_DESC_DEFAULT;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
 
if (portid >= rte_eth_dev_count())
rte_exit(EXIT_FAILURE, "Invalid port\n");
 
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
retval = rte_eth_dev_configure(portid, 1, 1, &port_conf);
if (retval != 0)
rte_exit(EXIT_FAILURE, "port %u: configuration failed 
(res=%d)\n",
@@ -189,16 +205,22 @@
"failed (res=%d)\n", portid, retval);
 
/* RX setup */
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
retval = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
-   rte_eth_dev_socket_id(portid), NULL,
+   rte_eth_dev_socket_id(portid),
+   &rxq_conf,
mbuf_pool);
if (retval < 0)
rte_exit(retval, " port %u: RX queue 0 setup failed (res=%d)",
portid, retval);
 
/* TX setup */
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
retval = rte_eth_tx_queue_setup(portid, 0, nb_txd,
-   rte_eth_dev_socket_id(portid), NULL);
+   rte_eth_dev_socket_id(portid), &txq_conf);
 
if (retval < 0)
rte_exit(retval, "port %u: TX queue 0 setup failed (res=%d)",
@@ -225,6 +247,9 @@
uint8_t i;
uint16_t nb_rxd = RTE_RX_DESC_DEFAULT;
uint16_t nb_txd = RTE_TX_DESC_DEFAULT;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
 
retval = rte_eth_bond_create("bond0", BONDING_MODE_ALB,
0 /*SOCKET_ID_ANY*/);
@@ -234,6 +259,21 @@
 
BOND_PORT = retval;
 
+   rte_eth_dev_info_get(BOND_PORT, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  BOND_PORT, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  BOND_PORT, port_conf.txmode.offloads,
+

[dpdk-dev] [PATCH v2 11/39] examples/kni: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/kni/main.c | 66 +---
 1 file changed, 57 insertions(+), 9 deletions(-)

diff --git a/examples/kni/main.c b/examples/kni/main.c
index 3f17385..6a35579 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -124,14 +124,12 @@ struct kni_port_params {
 /* Options for configuring ethernet port */
 static struct rte_eth_conf port_conf = {
.rxmode = {
-   .header_split = 0,  /* Header Split disabled */
-   .hw_ip_checksum = 0,/* IP checksum offload disabled */
-   .hw_vlan_filter = 0,/* VLAN filtering disabled */
-   .jumbo_frame = 0,   /* Jumbo Frame Support disabled */
-   .hw_strip_crc = 1,  /* CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -607,10 +605,28 @@ struct kni_interface_stats {
int ret;
uint16_t nb_rxd = NB_RXD;
uint16_t nb_txd = NB_TXD;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
 
/* Initialise device and RX/TX queues */
RTE_LOG(INFO, APP, "Initialising port %u ...\n", (unsigned)port);
fflush(stdout);
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(port, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Could not configure port%u (%d)\n",
@@ -621,14 +637,19 @@ struct kni_interface_stats {
rte_exit(EXIT_FAILURE, "Could not adjust number of descriptors "
"for port%u (%d)\n", (unsigned)port, ret);
 
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(port, 0, nb_rxd,
-   rte_eth_dev_socket_id(port), NULL, pktmbuf_pool);
+   rte_eth_dev_socket_id(port), &rxq_conf, pktmbuf_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Could not setup up RX queue for "
"port%u (%d)\n", (unsigned)port, ret);
 
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(port, 0, nb_txd,
-   rte_eth_dev_socket_id(port), NULL);
+   rte_eth_dev_socket_id(port), &txq_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Could not setup up TX queue for "
"port%u (%d)\n", (unsigned)port, ret);
@@ -702,7 +723,10 @@ struct kni_interface_stats {
 kni_change_mtu(uint16_t port_id, unsigned int new_mtu)
 {
int ret;
+   uint16_t nb_rxd = NB_RXD;
struct rte_eth_conf conf;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_rxconf rxq_conf;
 
if (port_id >= rte_eth_dev_count()) {
RTE_LOG(ERR, APP, "Invalid port id %d\n", port_id);
@@ -717,19 +741,43 @@ struct kni_interface_stats {
memcpy(&conf, &port_conf, sizeof(conf));
/* Set new MTU */
if (new_mtu > ETHER_MAX_LEN)
-   conf.rxmode.jumbo_frame = 1;
+   conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
else
-   conf.rxmode.jumbo_frame = 0;
+   conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
 
/* mtu + length of header + length of FCS = max pkt length */
conf.rxmode.max_rx_pkt_len = new_mtu + KNI_ENET_HEADER_SIZE +
KNI_ENET_FCS_SIZE;
+   rte_eth_dev_info_get(port_id, &dev_info);
+   if ((dev_info.rx_offload_capa & conf.rxmode.offloads) !=
+conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port 

[dpdk-dev] [PATCH v2 12/39] examples/ip_fragmentation: convert to new offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
Acked-by: Konstantin Ananyev 
---
 examples/ip_fragmentation/main.c | 35 ---
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index 5aefe09..1bb0563 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -169,14 +169,16 @@ struct lcore_queue_conf {
.rxmode = {
.max_rx_pkt_len = JUMBO_FRAME_MAX_SIZE,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 1, /**< IP checksum offload enabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 1, /**< Jumbo Frame Support enabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_CHECKSUM |
+DEV_RX_OFFLOAD_JUMBO_FRAME |
+DEV_RX_OFFLOAD_CRC_STRIP),
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM |
+DEV_TX_OFFLOAD_MULTI_SEGS |
+DEV_TX_OFFLOAD_MBUF_FAST_FREE),
},
 };
 
@@ -905,6 +907,8 @@ struct rte_lpm6_config lpm6_config = {
 
/* initialize all ports */
for (portid = 0; portid < nb_ports; portid++) {
+   struct rte_eth_rxconf rxq_conf;
+
/* skip ports that are not enabled */
if ((enabled_port_mask & (1 << portid)) == 0) {
printf("Skipping disabled port %d\n", portid);
@@ -949,6 +953,20 @@ struct rte_lpm6_config lpm6_config = {
n_tx_queue = nb_lcores;
if (n_tx_queue > MAX_TX_QUEUE_PER_PORT)
n_tx_queue = MAX_TX_QUEUE_PER_PORT;
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
&port_conf);
if (ret < 0) {
@@ -967,8 +985,10 @@ struct rte_lpm6_config lpm6_config = {
}
 
/* init one RX queue */
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
-socket, NULL,
+socket, &rxq_conf,
 socket_direct_pool[socket]);
if (ret < 0) {
printf("\n");
@@ -992,7 +1012,8 @@ struct rte_lpm6_config lpm6_config = {
fflush(stdout);
 
txconf = &dev_info.default_txconf;
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
 socket, txconf);
if (ret < 0) {
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 10/39] examples/exception_path: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/exception_path/main.c | 37 +
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c
index f8f5bbd..dc0546a 100644
--- a/examples/exception_path/main.c
+++ b/examples/exception_path/main.c
@@ -107,16 +107,14 @@
  */
 
 /* Options for configuring ethernet port */
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
.rxmode = {
-   .header_split = 0,  /* Header Split disabled */
-   .hw_ip_checksum = 0,/* IP checksum offload disabled */
-   .hw_vlan_filter = 0,/* VLAN filtering disabled */
-   .jumbo_frame = 0,   /* Jumbo Frame Support disabled */
-   .hw_strip_crc = 1,  /* CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -447,10 +445,28 @@ static int tap_create(char *name)
int ret;
uint16_t nb_rxd = NB_RXD;
uint16_t nb_txd = NB_TXD;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
 
/* Initialise device and RX/TX queues */
PRINT_INFO("Initialising port %u ...", port);
fflush(stdout);
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(port, 1, 1, &port_conf);
if (ret < 0)
FATAL_ERROR("Could not configure port%u (%d)", port, ret);
@@ -460,17 +476,22 @@ static int tap_create(char *name)
FATAL_ERROR("Could not adjust number of descriptors for port%u 
(%d)",
port, ret);
 
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(port, 0, nb_rxd,
rte_eth_dev_socket_id(port),
-   NULL,
+   &rxq_conf,
pktmbuf_pool);
if (ret < 0)
FATAL_ERROR("Could not setup up RX queue for port%u (%d)",
port, ret);
 
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(port, 0, nb_txd,
rte_eth_dev_socket_id(port),
-   NULL);
+   &txq_conf);
if (ret < 0)
FATAL_ERROR("Could not setup up TX queue for port%u (%d)",
port, ret);
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 13/39] examples/ip_pipeline: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/ip_pipeline/config_parse.c | 14 --
 examples/ip_pipeline/init.c | 26 ++
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/examples/ip_pipeline/config_parse.c 
b/examples/ip_pipeline/config_parse.c
index 3211c6a..a16d1a5 100644
--- a/examples/ip_pipeline/config_parse.c
+++ b/examples/ip_pipeline/config_parse.c
@@ -97,14 +97,8 @@
.rxmode = {
.mq_mode = ETH_MQ_RX_NONE,
 
-   .header_split   = 0, /* Header split */
-   .hw_ip_checksum = 0, /* IP checksum offload */
-   .hw_vlan_filter = 0, /* VLAN filtering */
-   .hw_vlan_strip  = 0, /* VLAN strip */
-   .hw_vlan_extend = 0, /* Extended VLAN */
-   .jumbo_frame= 0, /* Jumbo frame support */
-   .hw_strip_crc   = 1, /* CRC strip by HW */
-   .enable_scatter = 0, /* Scattered packets RX handler */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
 
.max_rx_pkt_len = 9000, /* Jumbo frame max packet len */
.split_hdr_size = 0, /* Header split buffer size */
@@ -118,6 +112,7 @@
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
.lpbk_mode = 0,
},
@@ -158,8 +153,7 @@
},
.tx_rs_thresh = 0,
.tx_free_thresh = 0,
-   .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
-   ETH_TXQ_FLAGS_NOOFFLOADS,
+   .txq_flags = ETH_TXQ_FLAGS_IGNORE,
.tx_deferred_start = 0,
}
 };
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index e56e404..85eeb2d 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -876,10 +876,10 @@
uint32_t i;
 
if (is_any_swq_frag_or_ras(app)) {
-   for (i = 0; i < app->n_pktq_hwq_out; i++) {
-   struct app_pktq_hwq_out_params *p_txq = 
&app->hwq_out_params[i];
-
-   p_txq->conf.txq_flags &= ~ETH_TXQ_FLAGS_NOMULTSEGS;
+   for (i = 0; i < app->n_links; i++) {
+   struct app_link_params *p_link = &app->link_params[i];
+   p_link->conf.txmode.offloads |=
+   DEV_TX_OFFLOAD_MULTI_SEGS;
}
}
 }
@@ -962,6 +962,7 @@
 
for (i = 0; i < app->n_links; i++) {
struct app_link_params *p_link = &app->link_params[i];
+   struct rte_eth_dev_info dev_info;
uint32_t link_id, n_hwq_in, n_hwq_out, j;
int status;
 
@@ -978,6 +979,21 @@
n_hwq_out);
 
/* LINK */
+   rte_eth_dev_info_get(p_link->pmd_id, &dev_info);
+   if ((dev_info.rx_offload_capa & p_link->conf.rxmode.offloads) !=
+   p_link->conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  p_link->pmd_id, p_link->conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & p_link->conf.txmode.offloads) !=
+   p_link->conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  p_link->pmd_id, p_link->conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
status = rte_eth_dev_configure(
p_link->pmd_id,
n_hwq_in,
@@ -1019,6 +1035,7 @@
p_rxq->name,
status);
 
+   p_rxq->conf.offloads = p_link->conf.rxmode.offloads;
status = rte_eth_rx_queue_setup(
p_link->pmd_id,
rxq_queue_id,
@@ -1060,6 +1077,7 @@
p_txq->name,
status);
 
+   p_txq->conf.offloads = p_link->conf.txmode.offloads;
status = rte_eth_tx_queue_setup(
p_link->pmd_id,

[dpdk-dev] [PATCH v2 16/39] examples/ipv4_multicast: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/ipv4_multicast/main.c | 33 ++---
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c
index 1c58516..ddefd71 100644
--- a/examples/ipv4_multicast/main.c
+++ b/examples/ipv4_multicast/main.c
@@ -138,14 +138,13 @@ struct lcore_queue_conf {
.rxmode = {
.max_rx_pkt_len = JUMBO_FRAME_MAX_SIZE,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 1, /**< Jumbo Frame Support enabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_JUMBO_FRAME |
+DEV_RX_OFFLOAD_CRC_STRIP),
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MULTI_SEGS,
},
 };
 
@@ -714,6 +713,8 @@ struct mcast_group_params {
 
/* initialize all ports */
for (portid = 0; portid < nb_ports; portid++) {
+   struct rte_eth_rxconf rxq_conf;
+
/* skip ports that are not enabled */
if ((enabled_port_mask & (1 << portid)) == 0) {
printf("Skipping disabled port %d\n", portid);
@@ -748,6 +749,21 @@ struct mcast_group_params {
n_tx_queue = nb_lcores;
if (n_tx_queue > MAX_TX_QUEUE_PER_PORT)
n_tx_queue = MAX_TX_QUEUE_PER_PORT;
+
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
&port_conf);
if (ret < 0)
@@ -769,9 +785,11 @@ struct mcast_group_params {
queueid = 0;
printf("rxq=%hu ", queueid);
fflush(stdout);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd,
 rte_eth_dev_socket_id(portid),
-NULL,
+&rxq_conf,
 packet_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, 
port=%d\n",
@@ -787,7 +805,8 @@ struct mcast_group_params {
fflush(stdout);
 
txconf = &dev_info.default_txconf;
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
 
rte_lcore_to_socket_id(lcore_id), txconf);
if (ret < 0)
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 14/39] examples/ip_reassembly: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/ip_reassembly/main.c | 35 ---
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index 756f90e..5c0f55a 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -193,11 +193,10 @@ struct lcore_queue_conf {
.mq_mode= ETH_MQ_RX_RSS,
.max_rx_pkt_len = JUMBO_FRAME_MAX_SIZE,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 1, /**< IP checksum offload enabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 1, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_CHECKSUM |
+DEV_RX_OFFLOAD_JUMBO_FRAME |
+DEV_RX_OFFLOAD_CRC_STRIP),
},
.rx_adv_conf = {
.rss_conf = {
@@ -207,6 +206,9 @@ struct lcore_queue_conf {
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM |
+DEV_TX_OFFLOAD_MULTI_SEGS |
+DEV_TX_OFFLOAD_MBUF_FAST_FREE),
},
 };
 
@@ -1052,6 +1054,8 @@ struct rte_lpm6_config lpm6_config = {
 
/* initialize all ports */
for (portid = 0; portid < nb_ports; portid++) {
+   struct rte_eth_rxconf rxq_conf;
+
/* skip ports that are not enabled */
if ((enabled_port_mask & (1 << portid)) == 0) {
printf("\nSkipping disabled port %d\n", portid);
@@ -1104,6 +1108,20 @@ struct rte_lpm6_config lpm6_config = {
n_tx_queue = nb_lcores;
if (n_tx_queue > MAX_TX_QUEUE_PER_PORT)
n_tx_queue = MAX_TX_QUEUE_PER_PORT;
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
&port_conf);
if (ret < 0) {
@@ -1114,8 +1132,10 @@ struct rte_lpm6_config lpm6_config = {
}
 
/* init one RX queue */
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
-socket, NULL,
+socket, &rxq_conf,
 rxq->pool);
if (ret < 0) {
printf("\n");
@@ -1140,7 +1160,8 @@ struct rte_lpm6_config lpm6_config = {
fflush(stdout);
 
txconf = &dev_info.default_txconf;
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
 
ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
socket, txconf);
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 15/39] examples/ipsec-secgw: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/ipsec-secgw/ipsec-secgw.c | 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index c98454a..1e8af8d 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -217,6 +217,9 @@ struct lcore_conf {
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM |
+DEV_TX_OFFLOAD_MULTI_SEGS |
+DEV_TX_OFFLOAD_MBUF_FAST_FREE),
},
 };
 
@@ -1394,6 +1397,20 @@ struct ipsec_traffic {
if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SECURITY)
port_conf.txmode.offloads |= DEV_TX_OFFLOAD_SECURITY;
 
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
&port_conf);
if (ret < 0)
@@ -1420,7 +1437,8 @@ struct ipsec_traffic {
printf("Setup txq=%u,%d,%d\n", lcore_id, tx_queueid, socket_id);
 
txconf = &dev_info.default_txconf;
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
 
ret = rte_eth_tx_queue_setup(portid, tx_queueid, nb_txd,
socket_id, txconf);
@@ -1434,6 +1452,8 @@ struct ipsec_traffic {
 
/* init RX queues */
for (queue = 0; queue < qconf->nb_rx_queue; ++queue) {
+   struct rte_eth_rxconf rxq_conf;
+
if (portid != qconf->rx_queue_list[queue].port_id)
continue;
 
@@ -1442,8 +1462,10 @@ struct ipsec_traffic {
printf("Setup rxq=%d,%d,%d\n", portid, rx_queueid,
socket_id);
 
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, rx_queueid,
-   nb_rxd, socket_id, NULL,
+   nb_rxd, socket_id, &rxq_conf,
socket_ctx[socket_id].mbuf_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE,
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 17/39] examples/link_status_interrupt: convert to new offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/link_status_interrupt/main.c | 37 +++---
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/examples/link_status_interrupt/main.c 
b/examples/link_status_interrupt/main.c
index bc47dcc..e7716a3 100644
--- a/examples/link_status_interrupt/main.c
+++ b/examples/link_status_interrupt/main.c
@@ -105,17 +105,15 @@ struct lcore_queue_conf {
 
 struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS];
 
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
.rxmode = {
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
.intr_conf = {
.lsc = 1, /**< lsc interrupt feature enabled */
@@ -633,6 +631,9 @@ struct lsi_port_statistics {
 
/* Initialise each port */
for (portid = 0; portid < nb_ports; portid++) {
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
+
/* skip ports that are not enabled */
if ((lsi_enabled_port_mask & (1 << portid)) == 0) {
printf("Skipping disabled port %u\n", (unsigned) 
portid);
@@ -641,6 +642,21 @@ struct lsi_port_statistics {
/* init port */
printf("Initializing port %u... ", (unsigned) portid);
fflush(stdout);
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Cannot configure device: 
err=%d, port=%u\n",
@@ -666,9 +682,11 @@ struct lsi_port_statistics {
 
/* init one RX queue */
fflush(stdout);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
 rte_eth_dev_socket_id(portid),
-NULL,
+&rxq_conf,
 lsi_pktmbuf_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup: err=%d, 
port=%u\n",
@@ -676,9 +694,12 @@ struct lsi_port_statistics {
 
/* init one TX queue logical core on each port */
fflush(stdout);
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
rte_eth_dev_socket_id(portid),
-   NULL);
+   &txq_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: 
err=%d,port=%u\n",
  ret, (unsigned) portid);
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 18/39] examples/load_balancer: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/load_balancer/init.c | 36 +---
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/examples/load_balancer/init.c b/examples/load_balancer/init.c
index 3dab7f2..e348fc1 100644
--- a/examples/load_balancer/init.c
+++ b/examples/load_balancer/init.c
@@ -74,11 +74,9 @@
.rxmode = {
.mq_mode= ETH_MQ_RX_RSS,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 1, /**< IP checksum offload enabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_CHECKSUM |
+DEV_RX_OFFLOAD_CRC_STRIP),
},
.rx_adv_conf = {
.rss_conf = {
@@ -88,6 +86,7 @@
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -430,6 +429,9 @@
struct rte_mempool *pool;
uint16_t nic_rx_ring_size;
uint16_t nic_tx_ring_size;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
+   struct rte_eth_dev_info dev_info;
 
n_rx_queues = app_get_nic_rx_queues_per_port(port);
n_tx_queues = app.nic_tx_port_mask[port];
@@ -440,6 +442,21 @@
 
/* Init port */
printf("Initializing NIC port %u ...\n", port);
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(
port,
(uint8_t) n_rx_queues,
@@ -461,6 +478,8 @@
app.nic_rx_ring_size = nic_rx_ring_size;
app.nic_tx_ring_size = nic_tx_ring_size;
 
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
/* Init RX queues */
for (queue = 0; queue < APP_MAX_RX_QUEUES_PER_NIC_PORT; queue 
++) {
if (app.nic_rx_queue_mask[port][queue] == 0) {
@@ -478,7 +497,7 @@
queue,
(uint16_t) app.nic_rx_ring_size,
socket,
-   NULL,
+   &rxq_conf,
pool);
if (ret < 0) {
rte_panic("Cannot init RX queue %u for port %u 
(%d)\n",
@@ -486,6 +505,9 @@
}
}
 
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
/* Init TX queues */
if (app.nic_tx_port_mask[port] == 1) {
app_get_lcore_for_nic_tx(port, &lcore);
@@ -497,7 +519,7 @@
0,
(uint16_t) app.nic_tx_ring_size,
socket,
-   NULL);
+   &txq_conf);
if (ret < 0) {
rte_panic("Cannot init TX queue 0 for port %d 
(%d)\n",
port,
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 19/39] examples/multi_process: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/multi_process/l2fwd_fork/main.c   | 35 -
 examples/multi_process/symmetric_mp/main.c | 34 +++-
 2 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/examples/multi_process/l2fwd_fork/main.c 
b/examples/multi_process/l2fwd_fork/main.c
index deace27..3451b51 100644
--- a/examples/multi_process/l2fwd_fork/main.c
+++ b/examples/multi_process/l2fwd_fork/main.c
@@ -156,14 +156,12 @@ struct cpu_aff_arg{
 static const struct rte_eth_conf port_conf = {
.rxmode = {
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -1064,6 +1062,9 @@ struct l2fwd_port_statistics {
 
/* Initialise each port */
for (portid = 0; portid < nb_ports; portid++) {
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
+
/* skip ports that are not enabled */
if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
printf("Skipping disabled port %u\n", (unsigned) 
portid);
@@ -1073,6 +1074,21 @@ struct l2fwd_port_statistics {
/* init port */
printf("Initializing port %u... ", (unsigned) portid);
fflush(stdout);
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Cannot configure device: 
err=%d, port=%u\n",
@@ -1089,9 +1105,11 @@ struct l2fwd_port_statistics {
 
/* init one RX queue */
fflush(stdout);
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd,
 rte_eth_dev_socket_id(portid),
-NULL,
+&rxq_conf,
 l2fwd_pktmbuf_pool[portid]);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, 
port=%u\n",
@@ -1099,9 +1117,12 @@ struct l2fwd_port_statistics {
 
/* init one TX queue on each port */
fflush(stdout);
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.tx_offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, 0, nb_txd,
rte_eth_dev_socket_id(portid),
-   NULL);
+   &txq_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup:err=%d, 
port=%u\n",
ret, (unsigned) portid);
diff --git a/examples/multi_process/symmetric_mp/main.c 
b/examples/multi_process/symmetric_mp/main.c
index 6fb285c..d3b9c62 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -207,11 +207,9 @@ struct port_stats{
.rxmode = {
.mq_mode= ETH_MQ_RX_RSS,
.split_hdr_size = 0,
-   .header_split  

[dpdk-dev] [PATCH v2 21/39] examples/performance-thread: convert to new offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/performance-thread/l3fwd-thread/main.c | 41 +++-
 1 file changed, 31 insertions(+), 10 deletions(-)

diff --git a/examples/performance-thread/l3fwd-thread/main.c 
b/examples/performance-thread/l3fwd-thread/main.c
index fa65234..2d61f03 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -335,11 +335,9 @@ struct tx_thread_params {
.mq_mode = ETH_MQ_RX_RSS,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 1, /**< IP checksum offload enabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_CHECKSUM |
+DEV_RX_OFFLOAD_CRC_STRIP),
},
.rx_adv_conf = {
.rss_conf = {
@@ -349,6 +347,7 @@ struct tx_thread_params {
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -2999,7 +2998,10 @@ static int parse_max_pkt_len(const char *pktlen)
0};
 
printf("jumbo frame is enabled - disabling 
simple TX path\n");
-   port_conf.rxmode.jumbo_frame = 1;
+   port_conf.rxmode.offloads |=
+   DEV_RX_OFFLOAD_JUMBO_FRAME;
+   port_conf.txmode.offloads |=
+   DEV_TX_OFFLOAD_MULTI_SEGS;
 
/* if no max-pkt-len set, use the default value 
ETHER_MAX_LEN */
if (0 == getopt_long(argc, argvopt, "", 
&lenopts,
@@ -3567,6 +3569,21 @@ static void convert_ipv6_5tuple(struct ipv6_5tuple *key1,
n_tx_queue = MAX_TX_QUEUE_PER_PORT;
printf("Creating queues: nb_rxq=%d nb_txq=%u... ",
nb_rx_queue, (unsigned)n_tx_queue);
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, nb_rx_queue,
(uint16_t)n_tx_queue, &port_conf);
if (ret < 0)
@@ -3612,10 +3629,9 @@ static void convert_ipv6_5tuple(struct ipv6_5tuple *key1,
printf("txq=%u,%d,%d ", lcore_id, queueid, socketid);
fflush(stdout);
 
-   rte_eth_dev_info_get(portid, &dev_info);
txconf = &dev_info.default_txconf;
-   if (port_conf.rxmode.jumbo_frame)
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
 socketid, txconf);
if (ret < 0)
@@ -3644,6 +3660,8 @@ static void convert_ipv6_5tuple(struct ipv6_5tuple *key1,
 
/* init RX queues */
for (queue = 0; queue < rx_thread[i].n_rx_queue; ++queue) {
+   struct rte_eth_rxconf rxq_conf;
+
portid = rx_thread[i].rx_queue_list[queue].port_id;
queueid = rx_thread[i].rx_queue_list[queue].queue_id;
 
@@ -3655,9 +3673,12 @@ static void convert_ipv6_5tuple(struct ipv6_5tuple *key1,
printf("rxq=%d,%d,%d ", portid, queueid, socketid);
fflush(stdout

[dpdk-dev] [PATCH v2 23/39] examples/qos_sched: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/qos_sched/init.c | 30 +++---
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/examples/qos_sched/init.c b/examples/qos_sched/init.c
index 038f042..696e15d 100644
--- a/examples/qos_sched/init.c
+++ b/examples/qos_sched/init.c
@@ -84,18 +84,16 @@ struct ring_thresh tx_thresh = {
 int mp_size = NB_MBUF;
 struct flow_conf qos_conf[MAX_DATA_STREAMS];
 
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
.rxmode = {
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_DCB_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -104,6 +102,7 @@ struct ring_thresh tx_thresh = {
 {
int ret;
struct rte_eth_link link;
+   struct rte_eth_dev_info dev_info;
struct rte_eth_rxconf rx_conf;
struct rte_eth_txconf tx_conf;
uint16_t rx_size;
@@ -125,12 +124,27 @@ struct ring_thresh tx_thresh = {
tx_conf.tx_thresh.wthresh = tx_thresh.wthresh;
tx_conf.tx_free_thresh = 0;
tx_conf.tx_rs_thresh = 0;
-   tx_conf.txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS | ETH_TXQ_FLAGS_NOOFFLOADS;
tx_conf.tx_deferred_start = 0;
+   tx_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
 
/* init port */
RTE_LOG(INFO, APP, "Initializing port %"PRIu16"... ", portid);
fflush(stdout);
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE,
@@ -149,6 +163,7 @@ struct ring_thresh tx_thresh = {
 
/* init one RX queue */
fflush(stdout);
+   rx_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(portid, 0, (uint16_t)ring_conf.rx_size,
rte_eth_dev_socket_id(portid), &rx_conf, mp);
if (ret < 0)
@@ -158,6 +173,7 @@ struct ring_thresh tx_thresh = {
 
/* init one TX queue */
fflush(stdout);
+   tx_conf.offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(portid, 0,
(uint16_t)ring_conf.tx_size, rte_eth_dev_socket_id(portid), 
&tx_conf);
if (ret < 0)
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 22/39] examples/qos_meter: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/qos_meter/main.c | 61 +-
 1 file changed, 54 insertions(+), 7 deletions(-)

diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index 67b4a75..5b0e3ae 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -85,11 +85,9 @@
.mq_mode= ETH_MQ_RX_RSS,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
-   .header_split   = 0,
-   .hw_ip_checksum = 1,
-   .hw_vlan_filter = 0,
-   .jumbo_frame= 0,
-   .hw_strip_crc   = 1,
+   .ignore_offload_bitfield = 1,
+   .offloads = (DEV_RX_OFFLOAD_CHECKSUM |
+DEV_RX_OFFLOAD_CRC_STRIP),
},
.rx_adv_conf = {
.rss_conf = {
@@ -99,6 +97,7 @@
},
.txmode = {
.mq_mode = ETH_DCB_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -310,6 +309,10 @@ static __attribute__((noreturn)) int
uint32_t lcore_id;
uint16_t nb_rxd = NIC_RX_QUEUE_DESC;
uint16_t nb_txd = NIC_TX_QUEUE_DESC;
+   struct rte_eth_conf conf;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
+   struct rte_eth_dev_info dev_info;
int ret;
 
/* EAL init */
@@ -335,6 +338,22 @@ static __attribute__((noreturn)) int
rte_exit(EXIT_FAILURE, "Buffer pool creation error\n");
 
/* NIC init */
+   rte_eth_dev_info_get(port_rx, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_rx, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_rx, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+   conf = port_conf;
ret = rte_eth_dev_configure(port_rx, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", 
port_rx, ret);
@@ -344,18 +363,41 @@ static __attribute__((noreturn)) int
rte_exit(EXIT_FAILURE, "Port %d adjust number of descriptors 
error (%d)\n",
port_rx, ret);
 
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(port_rx, NIC_RX_QUEUE, nb_rxd,
rte_eth_dev_socket_id(port_rx),
-   NULL, pool);
+   &rxq_conf, pool);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Port %d RX queue setup error (%d)\n", 
port_rx, ret);
 
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(port_rx, NIC_TX_QUEUE, nb_txd,
rte_eth_dev_socket_id(port_rx),
-   NULL);
+   &txq_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Port %d TX queue setup error (%d)\n", port_rx, 
ret);
 
+   rte_eth_dev_info_get(port_tx, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_tx, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_tx, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+   conf = port_conf;
+   conf.rxmode.offloads &= dev_info.rx_offload_capa;
+   conf.txmode.offloads &= dev_info.tx_offload_capa;
ret = rte_eth_dev_configure(port_tx, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", 
port_tx, ret);
@@ -367,12 +409,17 @@ static __attr

[dpdk-dev] [PATCH v2 20/39] examples/netmap_compat: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/netmap_compat/bridge/bridge.c |  8 +++-
 examples/netmap_compat/lib/compat_netmap.c | 27 +++--
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/examples/netmap_compat/bridge/bridge.c 
b/examples/netmap_compat/bridge/bridge.c
index 2f2b6ba..ec969e1 100644
--- a/examples/netmap_compat/bridge/bridge.c
+++ b/examples/netmap_compat/bridge/bridge.c
@@ -55,14 +55,12 @@
 struct rte_eth_conf eth_conf = {
.rxmode = {
.split_hdr_size = 0,
-   .header_split   = 0,
-   .hw_ip_checksum = 0,
-   .hw_vlan_filter = 0,
-   .jumbo_frame= 0,
-   .hw_strip_crc   = 1,
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
diff --git a/examples/netmap_compat/lib/compat_netmap.c 
b/examples/netmap_compat/lib/compat_netmap.c
index 12b3fcb..f145019 100644
--- a/examples/netmap_compat/lib/compat_netmap.c
+++ b/examples/netmap_compat/lib/compat_netmap.c
@@ -690,6 +690,9 @@ struct netmap_state {
int32_t ret;
uint16_t i;
uint16_t rx_slots, tx_slots;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
+   struct rte_eth_dev_info dev_info;
 
if (conf == NULL ||
portid >= RTE_DIM(ports) ||
@@ -710,6 +713,21 @@ struct netmap_state {
return -EINVAL;
}
 
+   rte_eth_dev_info_get(portid, &dev_info);
+   if ((dev_info.rx_offload_capa & conf->eth_conf->rxmode.offloads) !=
+   conf->eth_conf->rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, conf->eth_conf->rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & conf->eth_conf->txmode.offloads) !=
+   conf->eth_conf->txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  portid, conf->eth_conf->txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(portid, conf->nr_rx_rings,
conf->nr_tx_rings, conf->eth_conf);
 
@@ -727,9 +745,14 @@ struct netmap_state {
return ret;
}
 
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = conf->eth_conf->rxmode.offloads;
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = conf->eth_conf->txmode.offloads;
for (i = 0; i < conf->nr_tx_rings; i++) {
ret = rte_eth_tx_queue_setup(portid, i, tx_slots,
-   conf->socket_id, NULL);
+   conf->socket_id, &txq_conf);
 
if (ret < 0) {
RTE_LOG(ERR, USER1,
@@ -739,7 +762,7 @@ struct netmap_state {
}
 
ret = rte_eth_rx_queue_setup(portid, i, rx_slots,
-   conf->socket_id, NULL, conf->pool);
+   conf->socket_id, &rxq_conf, conf->pool);
 
if (ret < 0) {
RTE_LOG(ERR, USER1,
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 25/39] examples/tep_termination: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/tep_termination/vxlan_setup.c | 36 +++--
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/examples/tep_termination/vxlan_setup.c 
b/examples/tep_termination/vxlan_setup.c
index 1ad4ca3..4edde1b 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -95,17 +95,23 @@
RTE_TUNNEL_FILTER_OMAC_TENID_IMAC,};
 
 /* Options for configuring ethernet port */
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
.rxmode = {
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM |
+DEV_TX_OFFLOAD_UDP_CKSUM |
+DEV_TX_OFFLOAD_TCP_CKSUM |
+DEV_TX_OFFLOAD_SCTP_CKSUM |
+DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
+DEV_TX_OFFLOAD_TCP_TSO |
+DEV_TX_OFFLOAD_MULTI_SEGS |
+DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
+DEV_TX_OFFLOAD_MBUF_FAST_FREE),
},
 };
 
@@ -154,7 +160,7 @@
 
rxconf = &dev_info.default_rxconf;
txconf = &dev_info.default_txconf;
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
 
if (port >= rte_eth_dev_count())
return -1;
@@ -162,6 +168,20 @@
rx_rings = nb_devices;
 
/* Configure ethernet device. */
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
return retval;
@@ -172,6 +192,7 @@
return retval;
 
/* Setup the queues. */
+   rxconf->offloads = port_conf.rxmode.offloads;
for (q = 0; q < rx_rings; q++) {
retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
rte_eth_dev_socket_id(port),
@@ -180,6 +201,7 @@
if (retval < 0)
return retval;
}
+   txconf->offloads = port_conf.txmode.offloads;
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(port, q, tx_ring_size,
rte_eth_dev_socket_id(port),
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 26/39] examples/vhost: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/vhost/main.c | 41 ++---
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 89a61f0..5e0c680 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -145,21 +145,24 @@
.rxmode = {
.mq_mode= ETH_MQ_RX_VMDQ_ONLY,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
+   .ignore_offload_bitfield = 1,
/*
-* It is necessary for 1G NIC such as I350,
+* VLAN strip is necessary for 1G NIC such as I350,
 * this fixes bug of ipv4 forwarding in guest can't
 * forward pakets from one virtio dev to another virtio dev.
 */
-   .hw_vlan_strip  = 1, /**< VLAN strip enabled. */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .offloads = (DEV_RX_OFFLOAD_CRC_STRIP |
+DEV_RX_OFFLOAD_VLAN_STRIP),
},
 
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = (DEV_TX_OFFLOAD_IPV4_CKSUM |
+DEV_TX_OFFLOAD_TCP_CKSUM |
+DEV_TX_OFFLOAD_VLAN_INSERT |
+DEV_TX_OFFLOAD_MULTI_SEGS |
+DEV_TX_OFFLOAD_TCP_TSO |
+DEV_TX_OFFLOAD_MBUF_FAST_FREE),
},
.rx_adv_conf = {
/*
@@ -176,6 +179,7 @@
},
 };
 
+
 static unsigned lcore_ids[RTE_MAX_LCORE];
 static uint16_t ports[RTE_MAX_ETHPORTS];
 static unsigned num_ports = 0; /**< The number of ports specified in command 
line */
@@ -288,9 +292,7 @@ struct mbuf_table {
rxconf = &dev_info.default_rxconf;
txconf = &dev_info.default_txconf;
rxconf->rx_drop_en = 1;
-
-   /* Enable vlan offload */
-   txconf->txq_flags &= ~ETH_TXQ_FLAGS_NOVLANOFFL;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
 
/*configure the number of supported virtio devices based on VMDQ limits 
*/
num_devices = dev_info.max_vmdq_pools;
@@ -332,6 +334,20 @@ struct mbuf_table {
 
rx_rings = (uint16_t)dev_info.max_rx_queues;
/* Configure ethernet device. */
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0) {
RTE_LOG(ERR, VHOST_PORT, "Failed to configure port %u: %s.\n",
@@ -353,6 +369,7 @@ struct mbuf_table {
}
 
/* Setup the queues. */
+   rxconf->offloads = port_conf.rxmode.offloads;
for (q = 0; q < rx_rings; q ++) {
retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
rte_eth_dev_socket_id(port),
@@ -365,6 +382,7 @@ struct mbuf_table {
return retval;
}
}
+   txconf->offloads = port_conf.txmode.offloads;
for (q = 0; q < tx_rings; q ++) {
retval = rte_eth_tx_queue_setup(port, q, tx_ring_size,
rte_eth_dev_socket_id(port),
@@ -624,7 +642,8 @@ struct mbuf_table {
} else {
mergeable = !!ret;
if (ret) {
-   
vmdq_conf_default.rxmode.jumbo_frame = 1;
+   
vmdq_conf_default.rxmode.offloads |=
+   
DEV_RX_OFFLOAD_JUMBO_FRAME;

vmdq_conf_default.rxmode.max_rx_pkt_len
= JUMBO_FRAME_MAX_SIZE;

[dpdk-dev] [PATCH v2 24/39] examples/quota_watermark: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/quota_watermark/qw/init.c | 37 ++---
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/examples/quota_watermark/qw/init.c 
b/examples/quota_watermark/qw/init.c
index 37b0362..74cb054 100644
--- a/examples/quota_watermark/qw/init.c
+++ b/examples/quota_watermark/qw/init.c
@@ -50,17 +50,15 @@
 #include "../include/conf.h"
 
 
-static const struct rte_eth_conf port_conf = {
+static struct rte_eth_conf port_conf = {
.rxmode = {
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP csum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame disabled */
-   .hw_strip_crc   = 1, /**< CRC stripped by hardware */
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
.txmode = {
.mq_mode = ETH_DCB_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
 };
 
@@ -78,9 +76,27 @@ void configure_eth_port(uint16_t port_id)
int ret;
uint16_t nb_rxd = RX_DESC_PER_QUEUE;
uint16_t nb_txd = TX_DESC_PER_QUEUE;
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_txconf txq_conf;
+   struct rte_eth_dev_info dev_info;
 
rte_eth_dev_stop(port_id);
 
+   rte_eth_dev_info_get(port_id, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_id, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_id, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(port_id, 1, 1, &port_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Cannot configure port %u (error %d)\n",
@@ -93,9 +109,11 @@ void configure_eth_port(uint16_t port_id)
(unsigned int) port_id, ret);
 
/* Initialize the port's RX queue */
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
ret = rte_eth_rx_queue_setup(port_id, 0, nb_rxd,
rte_eth_dev_socket_id(port_id),
-   NULL,
+   &rxq_conf,
mbuf_pool);
if (ret < 0)
rte_exit(EXIT_FAILURE,
@@ -103,9 +121,12 @@ void configure_eth_port(uint16_t port_id)
(unsigned int) port_id, ret);
 
/* Initialize the port's TX queue */
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(port_id, 0, nb_txd,
rte_eth_dev_socket_id(port_id),
-   NULL);
+   &txq_conf);
if (ret < 0)
rte_exit(EXIT_FAILURE,
"Failed to setup TX queue on port %u (error 
%d)\n",
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 27/39] examples/vmdq: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/vmdq/main.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c
index 84e9937..069960c 100644
--- a/examples/vmdq/main.c
+++ b/examples/vmdq/main.c
@@ -94,14 +94,12 @@
.rxmode = {
.mq_mode= ETH_MQ_RX_VMDQ_ONLY,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
+   .ignore_offload_bitfield = 1,
},
 
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
.rx_adv_conf = {
/*
@@ -188,6 +186,7 @@
 {
struct rte_eth_dev_info dev_info;
struct rte_eth_rxconf *rxconf;
+   struct rte_eth_txconf *txconf;
struct rte_eth_conf port_conf;
uint16_t rxRings, txRings;
uint16_t rxRingSize = RTE_TEST_RX_DESC_DEFAULT;
@@ -245,6 +244,22 @@
 */
rxRings = (uint16_t)dev_info.max_rx_queues;
txRings = (uint16_t)dev_info.max_tx_queues;
+
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
if (retval != 0)
return retval;
@@ -260,9 +275,11 @@
return -1;
}
 
-   rte_eth_dev_info_get(port, &dev_info);
rxconf = &dev_info.default_rxconf;
rxconf->rx_drop_en = 1;
+   txconf = &dev_info.default_txconf;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
for (q = 0; q < rxRings; q++) {
retval = rte_eth_rx_queue_setup(port, q, rxRingSize,
rte_eth_dev_socket_id(port),
@@ -277,7 +294,7 @@
for (q = 0; q < txRings; q++) {
retval = rte_eth_tx_queue_setup(port, q, txRingSize,
rte_eth_dev_socket_id(port),
-   NULL);
+   txconf);
if (retval < 0) {
printf("initialise tx queue %d failed\n", q);
return retval;
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 28/39] examples/vmdq_dcb: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/vmdq_dcb/main.c | 27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index 9dad2b8..50a6bf5 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -100,13 +100,11 @@
.rxmode = {
.mq_mode= ETH_MQ_RX_VMDQ_DCB,
.split_hdr_size = 0,
-   .header_split   = 0, /**< Header Split disabled */
-   .hw_ip_checksum = 0, /**< IP checksum offload disabled */
-   .hw_vlan_filter = 0, /**< VLAN filtering disabled */
-   .jumbo_frame= 0, /**< Jumbo Frame Support disabled */
+   .ignore_offload_bitfield = 1,
},
.txmode = {
.mq_mode = ETH_MQ_TX_VMDQ_DCB,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
/*
 * should be overridden separately in code with
@@ -228,6 +226,7 @@
uint16_t q;
uint16_t queues_per_pool;
uint32_t max_nb_pools;
+   struct rte_eth_txconf txq_conf;
 
/*
 * The max pool number from dev_info will be used to validate the pool
@@ -284,6 +283,21 @@
if (retval < 0)
return retval;
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
/*
 * Though in this example, all queues including pf queues are setup.
 * This is because VMDQ queues doesn't always start from zero, and the
@@ -316,10 +330,13 @@
}
}
 
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_conf.offloads = port_conf.txmode.offloads;
for (q = 0; q < num_queues; q++) {
retval = rte_eth_tx_queue_setup(port, q, txRingSize,
rte_eth_dev_socket_id(port),
-   NULL);
+   &txq_conf);
if (retval < 0) {
printf("initialize tx queue %d failed\n", q);
return retval;
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 29/39] examples/vm_power_manager: convert to new offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
Acked-by: David Hunt 
---
 examples/vm_power_manager/main.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c
index 399fbdd..3248f75 100644
--- a/examples/vm_power_manager/main.c
+++ b/examples/vm_power_manager/main.c
@@ -74,7 +74,13 @@
 
 //
 static const struct rte_eth_conf port_conf_default = {
-   .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
+   .rxmode = {
+   .max_rx_pkt_len = ETHER_MAX_LEN,
+   .ignore_offload_bitfield = 1,
+   },
+   .txmode = {
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
+   },
 };
 
 static inline int
@@ -84,10 +90,28 @@
const uint16_t rx_rings = 1, tx_rings = 1;
int retval;
uint16_t q;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_txconf txq_conf;
 
if (port >= rte_eth_dev_count())
return -1;
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+
/* Configure the Ethernet device. */
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
@@ -101,10 +125,13 @@
return retval;
}
 
+   txq_conf = dev_info.default_txconf;
+   txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txq_cont.offloads = port_conf.txmode.offloads
/* Allocate and set up 1 TX queue per Ethernet port. */
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
-   rte_eth_dev_socket_id(port), NULL);
+   rte_eth_dev_socket_id(port), &txq_conf);
if (retval < 0)
return retval;
}
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 31/39] examples/ethtool: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/ethtool/ethtool-app/main.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/ethtool/ethtool-app/main.c 
b/examples/ethtool/ethtool-app/main.c
index bbab2f6..8a1a5f3 100644
--- a/examples/ethtool/ethtool-app/main.c
+++ b/examples/ethtool/ethtool-app/main.c
@@ -124,9 +124,11 @@ static void setup_ports(struct app_config *app_cfg, int 
cnt_ports)
char str_name[16];
uint16_t nb_rxd = PORT_RX_QUEUE_SIZE;
uint16_t nb_txd = PORT_TX_QUEUE_SIZE;
+   struct rte_eth_txconf txconf;
 
memset(&cfg_port, 0, sizeof(cfg_port));
cfg_port.txmode.mq_mode = ETH_MQ_TX_NONE;
+   cfg_port.rxmode.ignore_offload_bitfield = 1;
 
for (idx_port = 0; idx_port < cnt_ports; idx_port++) {
struct app_port *ptr_port = &app_cfg->ports[idx_port];
@@ -160,6 +162,7 @@ static void setup_ports(struct app_config *app_cfg, int 
cnt_ports)
 &nb_txd) < 0)
rte_exit(EXIT_FAILURE,
 "rte_eth_dev_adjust_nb_rx_tx_desc failed");
+
if (rte_eth_rx_queue_setup(
idx_port, 0, nb_rxd,
rte_eth_dev_socket_id(idx_port), NULL,
@@ -167,9 +170,11 @@ static void setup_ports(struct app_config *app_cfg, int 
cnt_ports)
rte_exit(EXIT_FAILURE,
 "rte_eth_rx_queue_setup failed"
);
+   txconf = dev_info.default_txconf;
+   txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
if (rte_eth_tx_queue_setup(
idx_port, 0, nb_txd,
-   rte_eth_dev_socket_id(idx_port), NULL) < 0)
+   rte_eth_dev_socket_id(idx_port), &txconf) < 0)
rte_exit(EXIT_FAILURE,
 "rte_eth_tx_queue_setup failed"
);
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 30/39] examples/distributor: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
Acked-by: Bruce Richardson 
---
 examples/distributor/main.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 61e6e6b..c2ef5cc 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -108,9 +108,11 @@
.rxmode = {
.mq_mode = ETH_MQ_RX_RSS,
.max_rx_pkt_len = ETHER_MAX_LEN,
+   .ignore_offload_bitfield = 1,
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
.rx_adv_conf = {
.rss_conf = {
@@ -140,10 +142,28 @@ struct output_buffer {
uint16_t q;
uint16_t nb_rxd = RX_RING_SIZE;
uint16_t nb_txd = TX_RING_SIZE;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_txconf txconf;
 
if (port >= rte_eth_dev_count())
return -1;
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+
retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
if (retval != 0)
return retval;
@@ -160,10 +180,13 @@ struct output_buffer {
return retval;
}
 
+   txconf = dev_info.default_txconf;
+   txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf.offloads = port_conf.txmode.offloads;
for (q = 0; q < txRings; q++) {
retval = rte_eth_tx_queue_setup(port, q, nb_txd,
rte_eth_dev_socket_id(port),
-   NULL);
+   &txconf);
if (retval < 0)
return retval;
}
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 32/39] examples/eventdev_pipeline: convert to new offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/eventdev_pipeline_sw_pmd/main.c | 29 +--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/examples/eventdev_pipeline_sw_pmd/main.c 
b/examples/eventdev_pipeline_sw_pmd/main.c
index 5f431d8..b7d1795 100644
--- a/examples/eventdev_pipeline_sw_pmd/main.c
+++ b/examples/eventdev_pipeline_sw_pmd/main.c
@@ -563,7 +563,11 @@ static int xdigit2val(unsigned char c)
static const struct rte_eth_conf port_conf_default = {
.rxmode = {
.mq_mode = ETH_MQ_RX_RSS,
-   .max_rx_pkt_len = ETHER_MAX_LEN
+   .max_rx_pkt_len = ETHER_MAX_LEN,
+   .ignore_offload_bitfield = 1,
+   },
+   .txmode = {
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
},
.rx_adv_conf = {
.rss_conf = {
@@ -578,10 +582,28 @@ static int xdigit2val(unsigned char c)
struct rte_eth_conf port_conf = port_conf_default;
int retval;
uint16_t q;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_txconf txconf;
 
if (port >= rte_eth_dev_count())
return -1;
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+
/* Configure the Ethernet device. */
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
@@ -595,10 +617,13 @@ static int xdigit2val(unsigned char c)
return retval;
}
 
+   txconf = dev_info.default_txconf;
+   txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf.offloads = port_conf_default.txmode.offloads;
/* Allocate and set up 1 TX queue per Ethernet port. */
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(port, q, tx_ring_size,
-   rte_eth_dev_socket_id(port), NULL);
+   rte_eth_dev_socket_id(port), &txconf);
if (retval < 0)
return retval;
}
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 33/39] examples/flow_classify: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/flow_classify/flow_classify.c | 31 +++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/examples/flow_classify/flow_classify.c 
b/examples/flow_classify/flow_classify.c
index 766f1dd..0a94348 100644
--- a/examples/flow_classify/flow_classify.c
+++ b/examples/flow_classify/flow_classify.c
@@ -89,7 +89,13 @@ enum {
 const char cb_port_delim[] = ":";
 
 static const struct rte_eth_conf port_conf_default = {
-   .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
+   .rxmode = {
+   .max_rx_pkt_len = ETHER_MAX_LEN,
+   .ignore_offload_bitfield = 1,
+   },
+   .txmode = {
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
+   },
 };
 
 struct flow_classifier {
@@ -216,10 +222,28 @@ enum {
const uint16_t rx_rings = 1, tx_rings = 1;
int retval;
uint16_t q;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_txconf txconf;
 
if (port >= rte_eth_dev_count())
return -1;
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+
/* Configure the Ethernet device. */
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
@@ -233,10 +257,13 @@ enum {
return retval;
}
 
+   txconf = dev_info.default_txconf;
+   txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf.offloads = port_conf.txmode.offloads;
/* Allocate and set up 1 TX queue per Ethernet port. */
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,
-   rte_eth_dev_socket_id(port), NULL);
+   rte_eth_dev_socket_id(port), &txconf);
if (retval < 0)
return retval;
}
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 34/39] examples/flow_filtering: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/flow_filtering/main.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
index 7d739b4..48648f0 100644
--- a/examples/flow_filtering/main.c
+++ b/examples/flow_filtering/main.c
@@ -138,20 +138,22 @@
struct rte_eth_conf port_conf = {
.rxmode = {
.split_hdr_size = 0,
-   /**< Header Split disabled */
-   .header_split   = 0,
-   /**< IP checksum offload disabled */
-   .hw_ip_checksum = 0,
-   /**< VLAN filtering disabled */
-   .hw_vlan_filter = 0,
-   /**< Jumbo Frame Support disabled */
-   .jumbo_frame= 0,
-   /**< CRC stripped by hardware */
-   .hw_strip_crc   = 1,
+   .ignore_offload_bitfield = 1,
+   .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
},
};
+   struct rte_eth_rxconf rxq_conf;
+   struct rte_eth_dev_info dev_info;
 
printf(":: initializing port: %d\n", port_id);
+   rte_eth_dev_info_get(port_id, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_id, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
ret = rte_eth_dev_configure(port_id,
nr_queues, nr_queues, &port_conf);
if (ret < 0) {
@@ -160,11 +162,13 @@
ret, port_id);
}
 
+   rxq_conf = dev_info.default_rxconf;
+   rxq_conf.offloads = port_conf.rxmode.offloads;
/* only set Rx queues: something we care only so far */
for (i = 0; i < nr_queues; i++) {
ret = rte_eth_rx_queue_setup(port_id, i, 512,
 rte_eth_dev_socket_id(port_id),
-NULL,
+&rxq_conf,
 mbuf_pool);
if (ret < 0) {
rte_exit(EXIT_FAILURE,
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 36/39] examples/ptpclient: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/ptpclient/ptpclient.c | 28 +---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index c53dad6..a4c709e 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -77,7 +77,13 @@
 static uint8_t ptp_enabled_ports[RTE_MAX_ETHPORTS];
 
 static const struct rte_eth_conf port_conf_default = {
-   .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
+   .rxmode = {
+   .max_rx_pkt_len = ETHER_MAX_LEN,
+   .ignore_offload_bitfield = 1,
+   },
+   .txmode = {
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
+   },
 };
 
 static const struct ether_addr ether_multicast = {
@@ -216,6 +222,22 @@ static inline uint64_t timespec64_to_ns(const struct 
timespec *ts)
if (port >= rte_eth_dev_count())
return -1;
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+
/* Configure the Ethernet device. */
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
@@ -239,9 +261,9 @@ static inline uint64_t timespec64_to_ns(const struct 
timespec *ts)
/* Setup txq_flags */
struct rte_eth_txconf *txconf;
 
-   rte_eth_dev_info_get(q, &dev_info);
txconf = &dev_info.default_txconf;
-   txconf->txq_flags = 0;
+   txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf->offloads = port_conf.txmode.offloads;
 
retval = rte_eth_tx_queue_setup(port, q, nb_txd,
rte_eth_dev_socket_id(port), txconf);
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 38/39] examples/server_node_efd: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/server_node_efd/server/init.c | 33 +
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/examples/server_node_efd/server/init.c 
b/examples/server_node_efd/server/init.c
index 0bcab8c..19d0ff4 100644
--- a/examples/server_node_efd/server/init.c
+++ b/examples/server_node_efd/server/init.c
@@ -123,14 +123,20 @@
 init_port(uint16_t port_num)
 {
/* for port configuration all features are off by default */
-   const struct rte_eth_conf port_conf = {
+   struct rte_eth_conf port_conf = {
.rxmode = {
-   .mq_mode = ETH_MQ_RX_RSS
-   }
+   .mq_mode = ETH_MQ_RX_RSS,
+   .ignore_offload_bitfield = 1,
+   },
+   .txmode = {
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
+   },
};
const uint16_t rx_rings = 1, tx_rings = num_nodes;
uint16_t rx_ring_size = RTE_MP_RX_DESC_DEFAULT;
uint16_t tx_ring_size = RTE_MP_TX_DESC_DEFAULT;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_txconf txconf;
 
uint16_t q;
int retval;
@@ -138,6 +144,22 @@
printf("Port %u init ... ", port_num);
fflush(stdout);
 
+   rte_eth_dev_info_get(port_num, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_num, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_num, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+
/*
 * Standard DPDK port initialisation - config port, then set up
 * rx and tx rings.
@@ -159,10 +181,13 @@
return retval;
}
 
+   txconf = dev_info.default_txconf;
+   txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf.offloads = port_conf.txmode.offloads;
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(port_num, q, tx_ring_size,
rte_eth_dev_socket_id(port_num),
-   NULL);
+   &txconf);
if (retval < 0)
return retval;
}
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 35/39] examples/packet_ordering: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
---
 examples/packet_ordering/main.c | 32 ++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c
index 3add7be..4a58e4d 100644
--- a/examples/packet_ordering/main.c
+++ b/examples/packet_ordering/main.c
@@ -64,7 +64,14 @@
 
 static struct rte_mempool *mbuf_pool;
 
-static struct rte_eth_conf port_conf_default;
+static struct rte_eth_conf port_conf_default = {
+   .rxmode = {
+   .ignore_offload_bitfield = 1,
+   },
+   .txmode = {
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
+   },
+};
 
 struct worker_thread_args {
struct rte_ring *ring_in;
@@ -293,10 +300,28 @@ struct send_thread_args {
uint16_t q;
uint16_t nb_rxd = RX_DESC_PER_QUEUE;
uint16_t nb_txd = TX_DESC_PER_QUEUE;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_txconf txconf;
+   struct rte_eth_conf port_conf = port_conf_default;
 
if (port_id > nb_ports)
return -1;
 
+   rte_eth_dev_info_get(port_id, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+   port_id, port_conf.rxmode.offloads,
+   dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port_id, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
ret = rte_eth_dev_configure(port_id, rxRings, txRings, 
&port_conf_default);
if (ret != 0)
return ret;
@@ -313,9 +338,12 @@ struct send_thread_args {
return ret;
}
 
+   txconf = dev_info.default_txconf;
+   txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf.offloads = port_conf.txmode.offloads;
for (q = 0; q < txRings; q++) {
ret = rte_eth_tx_queue_setup(port_id, q, nb_txd,
-   rte_eth_dev_socket_id(port_id), NULL);
+   rte_eth_dev_socket_id(port_id), &txconf);
if (ret < 0)
return ret;
}
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 37/39] examples/rxtx_callbacks: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
Acked-by: Bruce Richardson 
---
 examples/rxtx_callbacks/main.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c
index ca135d2..0f563f2 100644
--- a/examples/rxtx_callbacks/main.c
+++ b/examples/rxtx_callbacks/main.c
@@ -47,7 +47,13 @@
 #define BURST_SIZE 32
 
 static const struct rte_eth_conf port_conf_default = {
-   .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN, },
+   .rxmode = {
+   .max_rx_pkt_len = ETHER_MAX_LEN,
+   .ignore_offload_bitfield = 1,
+   },
+   .txmode = {
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
+   },
 };
 
 static unsigned nb_ports;
@@ -105,10 +111,28 @@
uint16_t nb_txd = TX_RING_SIZE;
int retval;
uint16_t q;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_txconf txconf;
 
if (port >= rte_eth_dev_count())
return -1;
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
return retval;
@@ -124,9 +148,12 @@
return retval;
}
 
+   txconf = dev_info.default_txconf;
+   txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf.offloads = port_conf.txmode.offloads;
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(port, q, nb_txd,
-   rte_eth_dev_socket_id(port), NULL);
+   rte_eth_dev_socket_id(port), &txconf);
if (retval < 0)
return retval;
}
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 39/39] examples/skeleton: convert to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler 
Acked-by: Bruce Richardson 
---
 examples/skeleton/basicfwd.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/examples/skeleton/basicfwd.c b/examples/skeleton/basicfwd.c
index e623754..02ce7ba 100644
--- a/examples/skeleton/basicfwd.c
+++ b/examples/skeleton/basicfwd.c
@@ -47,7 +47,13 @@
 #define BURST_SIZE 32
 
 static const struct rte_eth_conf port_conf_default = {
-   .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
+   .rxmode = {
+   .max_rx_pkt_len = ETHER_MAX_LEN,
+   .ignore_offload_bitfield = 1,
+   },
+   .txmode = {
+   .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE,
+   },
 };
 
 /* basicfwd.c: Basic DPDK skeleton forwarding example. */
@@ -65,10 +71,28 @@
uint16_t nb_txd = TX_RING_SIZE;
int retval;
uint16_t q;
+   struct rte_eth_dev_info dev_info;
+   struct rte_eth_txconf txconf;
 
if (port >= rte_eth_dev_count())
return -1;
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) !=
+   port_conf.rxmode.offloads) {
+   printf("Some Rx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.rxmode.offloads,
+  dev_info.rx_offload_capa);
+   }
+   if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) !=
+   port_conf.txmode.offloads) {
+   printf("Some Tx offloads are not supported "
+  "by port %d: requested 0x%lx supported 0x%lx\n",
+  port, port_conf.txmode.offloads,
+  dev_info.tx_offload_capa);
+   }
+
/* Configure the Ethernet device. */
retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
if (retval != 0)
@@ -86,10 +110,13 @@
return retval;
}
 
+   txconf = dev_info.default_txconf;
+   txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
+   txconf.offloads = port_conf.txmode.offloads;
/* Allocate and set up 1 TX queue per Ethernet port. */
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(port, q, nb_txd,
-   rte_eth_dev_socket_id(port), NULL);
+   rte_eth_dev_socket_id(port), &txconf);
if (retval < 0)
return retval;
}
-- 
1.8.3.1



Re: [dpdk-dev] [PATCH v3] doc: add a restriction to multi-process support

2017-12-12 Thread Mcnamara, John


> -Original Message-
> From: Chen, Junjie J
> Sent: Wednesday, November 29, 2017 5:17 PM
> To: Gonzalez Monroy, Sergio ; Mcnamara,
> John ; Tahhan, Maryam ;
> dev@dpdk.org
> Cc: Chen, Junjie J 
> Subject: [PATCH v3] doc: add a restriction to multi-process support
> 
> This patch add a restriction to multi-process support: secondary processes
> should only run alongside primary process with same DPDK version, so that
> secondary processes can use the same hugepage mmap layout as primary
> process.
> 
> Signed-off-by: Junjie Chen 

Could you mark the previous version of this patch as "Superseded":

http://dpdk.org/dev/patchwork/project/dpdk/list/?submitter=&state=&q=restriction+to+multi-process+support&archive=&delegate=


Otherwise:

Acked-by: John McNamara 




Re: [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: add target queues in flow actions

2017-12-12 Thread Anoob Joseph

Hi Nelio,


On 12/11/2017 07:34 PM, Nelio Laranjeiro wrote:

Mellanox INNOVA NIC needs to have final target queue actions to perform
inline crypto.

Signed-off-by: Nelio Laranjeiro 

---

Changes in v3:

  * removed PASSTHRU test for ingress.
  * removed check on configured queues for the queue action.

Changes in v2:

  * Test the rule by PASSTHRU/RSS/QUEUE and apply the first one validated.
---
  examples/ipsec-secgw/ipsec.c | 57 ++--
  examples/ipsec-secgw/ipsec.h |  2 +-
  2 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 17bd7620d..1b8b251c8 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -142,6 +142,7 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa 
*sa)
rte_eth_dev_get_sec_ctx(
sa->portid);
const struct rte_security_capability *sec_cap;
+   int ret = 0;
  
  			sa->sec_session = rte_security_session_create(ctx,

&sess_conf, ipsec_ctx->session_pool);
@@ -201,15 +202,67 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct 
ipsec_sa *sa)
sa->action[0].type = RTE_FLOW_ACTION_TYPE_SECURITY;
sa->action[0].conf = sa->sec_session;
  
-			sa->action[1].type = RTE_FLOW_ACTION_TYPE_END;

-
sa->attr.egress = (sa->direction ==
RTE_SECURITY_IPSEC_SA_DIR_EGRESS);
sa->attr.ingress = (sa->direction ==
RTE_SECURITY_IPSEC_SA_DIR_INGRESS);
+   if (sa->attr.ingress) {
+   uint8_t rss_key[40];
+   struct rte_eth_rss_conf rss_conf = {
+   .rss_key = rss_key,
+   .rss_key_len = 40,
+   };
+   struct rte_eth_dev *eth_dev;
+   union {
+   struct rte_flow_action_rss rss;
+   struct {
+   const struct rte_eth_rss_conf *rss_conf;
+   uint16_t num;
+   uint16_t queue[RTE_MAX_QUEUES_PER_PORT];
+   } local;
+   } action_rss;
+   unsigned int i;
+   unsigned int j;
+
+   sa->action[2].type = RTE_FLOW_ACTION_TYPE_END;
+   /* Try RSS. */
+   sa->action[1].type = RTE_FLOW_ACTION_TYPE_RSS;
+   sa->action[1].conf = &action_rss;
+   eth_dev = ctx->device;
+   rte_eth_dev_rss_hash_conf_get(sa->portid,
+ &rss_conf);
+   for (i = 0, j = 0;
+i < eth_dev->data->nb_rx_queues; ++i)
+   if (eth_dev->data->rx_queues[i])
+   action_rss.local.queue[j++] = i;
+   action_rss.local.num = j;
+   action_rss.local.rss_conf = &rss_conf;
+   ret = rte_flow_validate(sa->portid, &sa->attr,
+   sa->pattern, sa->action,
+   &err);
+   if (!ret)
+   goto flow_create;
+   /* Try Queue. */
+   sa->action[1].type = RTE_FLOW_ACTION_TYPE_QUEUE;
+   sa->action[1].conf =
+   &(struct rte_flow_action_queue){
+   .index = 0,
+   };
+   ret = rte_flow_validate(sa->portid, &sa->attr,
+   sa->pattern, sa->action,
+   &err);
+   if (ret)
+   goto flow_create_failure;
+   } else {
+   sa->action[1].type =
+   RTE_FLOW_ACTION_TYPE_PASSTHRU;
+   sa->action[2].type = RTE_FLOW_ACTION_TYPE_END;
We would need flow validate here also. And, for egress, the application 
will be able to set metadata (set_pkt_metadata API) per packet. So f

Re: [dpdk-dev] [PATCH 2/5] app/testpmd: remove txqflags

2017-12-12 Thread Maciej Czekaj



-- Oryginal message --

Thursday, December 7, 2017 1:05 AM, Ferruh Yigit:

On 12/4/2017 10:48 PM, Shahaf Shuler wrote:

Tuesday, December 5, 2017 12:31 AM, Ferruh Yigit:

On 11/23/2017 4:08 AM, Shahaf Shuler wrote:

Since testpmd is now using the new Ethdev offloads API there is no
need for the txqflags configuration.

txqflag command-line option (--txqflags=0x) and command

(port

config all txqflags value) are way to dynamically provide Tx offload
configuration to testpmd.

Why you are removing them without providing equivalent feature with
new offload APIs?

There is one, and this is why the new offloads API simplifies applications

life.

The txq_flags were introduced so application can disable some of the Tx

offloads from the time the Tx offloads were set by default.

Now the Tx offloads are all disabled by default. And there is an option to

set each one of the using DEV_TX_OFFLOAD_* flags.

Look on the Rx side (there the Rx offloads were disabled by default in the

old API). there is no rxq_flags.

I mean providing a testpmd command and command-line option.
Or am I missing it, after this update is there a way to update enabled Tx
offloads in testpmd via command and command-line?

There is a way to update via CLI
For example when doing "tso set  " the DEV_TX_OFFLOAD_TSO will be set
When doing tx_vlan add   the DEV_TX_OFFLOAD_VLAN_INSERT will be set
Same for every Tx offloads besides DEV_TX_OFFLOAD_MULTI_SEGS  and 
DEV_TX_OFFLOAD_MBUF_FAST_FREE which I added on separate patches.

But to make it precise you didn’t had before (with the txq_flags) a way to 
disable TSO from the command line (the is no TXQ flag for that) nor the tunnel 
TSO.


Patch 3/4 & 4/5 adds new command-line options to enable some of
recently introduced Tx offloads in testpmd, why not add a generic way
to update all Tx offloads instead of those two specific offloads?

Because those 2 new offloads were missing a way to set in testpmd.
The rest of the offloads can be set using the CLI commands exists today.

Am not sure we want every Tx offloads to be set from both CLI and

command line arguments.

It wasn't before (for example there was no --disable-tso flags).

I was thinking a generic command-line instead of introducing one for all,
overall single variable represents all offload values, why not set it at once, 
as
--txqflags you are removing in this patch.

We can do it. yes.


+1 for Ferruh. --txqflags argument was very handy in testing features in 
batch mode. Let us have something equivalent.





Also this patch removing ability to display current Tx offload

configuration

Can you point where ?

I mean following:

   -printf("  TX RS bit threshold=%d - TXQ flags=0x%"PRIx32"\n",
   -   tx_conf->tx_rs_thresh, tx_conf->txq_flags);
   +printf("  TX RS bit threshold=%d\n", tx_conf->tx_rs_thresh);

Why not an offloads replacement of this one?

Will be added.


Signed-off-by: Shahaf Shuler 
Acked-by: Nelio Laranjeiro 

<...>




[dpdk-dev] [PATCH v2 01/10] app/testpmd: fix port configuration print

2017-12-12 Thread Shahaf Shuler
The print of the port configuration was only according to configuration
of the first port.

Fixes: f2c5125a686a ("app/testpmd: use default Rx/Tx port configuration")
Cc: pablo.de.lara.gua...@intel.com
Cc: sta...@dpdk.org

Signed-off-by: Shahaf Shuler 
---
 app/test-pmd/config.c | 48 +-
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index cd2ac11..8a2d30c 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1655,33 +1655,45 @@ struct igb_ring_desc_16_bytes {
 void
 rxtx_config_display(void)
 {
-   printf("  %s packet forwarding%s - CRC stripping %s - "
-  "packets/burst=%d\n", cur_fwd_eng->fwd_mode_name,
+   portid_t pid;
+
+   printf("  %s packet forwarding%s packets/burst=%d\n",
+  cur_fwd_eng->fwd_mode_name,
   retry_enabled == 0 ? "" : " with retry",
-  rx_mode.hw_strip_crc ? "enabled" : "disabled",
   nb_pkt_per_burst);
 
if (cur_fwd_eng == &tx_only_engine || cur_fwd_eng == &flow_gen_engine)
printf("  packet len=%u - nb packet segments=%d\n",
(unsigned)tx_pkt_length, (int) tx_pkt_nb_segs);
 
-   struct rte_eth_rxconf *rx_conf = &ports[0].rx_conf;
-   struct rte_eth_txconf *tx_conf = &ports[0].tx_conf;
-
printf("  nb forwarding cores=%d - nb forwarding ports=%d\n",
   nb_fwd_lcores, nb_fwd_ports);
-   printf("  RX queues=%d - RX desc=%d - RX free threshold=%d\n",
-  nb_rxq, nb_rxd, rx_conf->rx_free_thresh);
-   printf("  RX threshold registers: pthresh=%d hthresh=%d wthresh=%d\n",
-  rx_conf->rx_thresh.pthresh, rx_conf->rx_thresh.hthresh,
-  rx_conf->rx_thresh.wthresh);
-   printf("  TX queues=%d - TX desc=%d - TX free threshold=%d\n",
-  nb_txq, nb_txd, tx_conf->tx_free_thresh);
-   printf("  TX threshold registers: pthresh=%d hthresh=%d wthresh=%d\n",
-  tx_conf->tx_thresh.pthresh, tx_conf->tx_thresh.hthresh,
-  tx_conf->tx_thresh.wthresh);
-   printf("  TX RS bit threshold=%d - TXQ flags=0x%"PRIx32"\n",
-  tx_conf->tx_rs_thresh, tx_conf->txq_flags);
+
+   RTE_ETH_FOREACH_DEV(pid) {
+   struct rte_eth_rxconf *rx_conf = &ports[pid].rx_conf;
+   struct rte_eth_txconf *tx_conf = &ports[pid].tx_conf;
+
+   printf("  port %d:\n", (unsigned int)pid);
+   printf("  CRC stripping %s\n",
+   ports[pid].dev_conf.rxmode.hw_strip_crc ?
+   "enabled" : "disabled");
+   printf("  RX queues=%d - RX desc=%d - RX free threshold=%d\n",
+   nb_rxq, nb_rxd, rx_conf->rx_free_thresh);
+   printf("  RX threshold registers: pthresh=%d hthresh=%d "
+  " wthresh=%d\n",
+   rx_conf->rx_thresh.pthresh,
+   rx_conf->rx_thresh.hthresh,
+   rx_conf->rx_thresh.wthresh);
+   printf("  TX queues=%d - TX desc=%d - TX free threshold=%d\n",
+   nb_txq, nb_txd, tx_conf->tx_free_thresh);
+   printf("  TX threshold registers: pthresh=%d hthresh=%d "
+  " wthresh=%d\n",
+   tx_conf->tx_thresh.pthresh,
+   tx_conf->tx_thresh.hthresh,
+   tx_conf->tx_thresh.wthresh);
+   printf("  TX RS bit threshold=%d - TXQ flags=0x%"PRIx32"\n",
+   tx_conf->tx_rs_thresh, tx_conf->txq_flags);
+   }
 }
 
 void
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 00/10] convert testpmd to new ethdev offloads API

2017-12-12 Thread Shahaf Shuler
This series is to convert testpmd application to the new offloads API [1].

on v2:
 - Splited the patchset to multiple patches to help with the review.
 - Removed wrong comments.
 - Removed redundent parenthesis.
 - Fixed port print parameters.
 - Introduced a new method to check if single port is stopped.
 - Cleanup for internal Tx offloads flags.

[1] http://dpdk.org/ml/archives/dev/2017-October/077329.html

Shahaf Shuler (10):
  app/testpmd: fix port configuration print
  app/testpmd: convert to new Ethdev Rx offloads API
  app/testpmd: support check of single port stop
  app/testpmd: convert to new Ethdev Tx offloads API
  app/testpmd: fix flowgen forwarding ol flags
  app/testpmd: cleanup internal Tx offloads flags field
  app/testpmd: add command line option for Tx offloads
  app/testpmd: remove txqflags
  app/testpmd: enforce offloads caps
  app/testpmd: fix on the flight VLAN configuration

 app/test-pmd/cmdline.c  | 501 +--
 app/test-pmd/config.c   | 177 +---
 app/test-pmd/csumonly.c |  40 +-
 app/test-pmd/flowgen.c  |  12 +-
 app/test-pmd/macfwd.c   |   8 +-
 app/test-pmd/macswap.c  |   8 +-
 app/test-pmd/parameters.c   |  59 +--
 app/test-pmd/testpmd.c  |  77 ++--
 app/test-pmd/testpmd.h  |  26 +-
 app/test-pmd/txonly.c   |   8 +-
 doc/guides/testpmd_app_ug/run_app.rst   |  17 +-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  11 -
 12 files changed, 541 insertions(+), 403 deletions(-)

-- 
1.8.3.1



[dpdk-dev] [PATCH v2 02/10] app/testpmd: convert to new Ethdev Rx offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev Rx offloads API has changed since:

commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")

Convert the application to use the new API. The is no functionality
changes rather simple conversion of the flags.

Signed-off-by: Shahaf Shuler 
---
 app/test-pmd/cmdline.c| 51 +++---
 app/test-pmd/config.c | 36 +++--
 app/test-pmd/parameters.c | 32 +-
 app/test-pmd/testpmd.c| 19 +++-
 4 files changed, 77 insertions(+), 61 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f71d963..d8c73a9 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1577,6 +1577,7 @@ struct cmd_config_max_pkt_len_result {
__attribute__((unused)) void *data)
 {
struct cmd_config_max_pkt_len_result *res = parsed_result;
+   uint64_t rx_offloads = rx_mode.offloads;
 
if (!all_ports_stopped()) {
printf("Please stop all ports first\n");
@@ -1594,14 +1595,16 @@ struct cmd_config_max_pkt_len_result {
 
rx_mode.max_rx_pkt_len = res->value;
if (res->value > ETHER_MAX_LEN)
-   rx_mode.jumbo_frame = 1;
+   rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
else
-   rx_mode.jumbo_frame = 0;
+   rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
} else {
printf("Unknown parameter\n");
return;
}
 
+   rx_mode.offloads = rx_offloads;
+
init_port_config();
 
cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
@@ -1703,6 +1706,7 @@ struct cmd_config_rx_mode_flag {
__attribute__((unused)) void *data)
 {
struct cmd_config_rx_mode_flag *res = parsed_result;
+   uint64_t rx_offloads = rx_mode.offloads;
 
if (!all_ports_stopped()) {
printf("Please stop all ports first\n");
@@ -1711,48 +1715,48 @@ struct cmd_config_rx_mode_flag {
 
if (!strcmp(res->name, "crc-strip")) {
if (!strcmp(res->value, "on"))
-   rx_mode.hw_strip_crc = 1;
+   rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
else if (!strcmp(res->value, "off"))
-   rx_mode.hw_strip_crc = 0;
+   rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "scatter")) {
-   if (!strcmp(res->value, "on"))
-   rx_mode.enable_scatter = 1;
-   else if (!strcmp(res->value, "off"))
-   rx_mode.enable_scatter = 0;
-   else {
+   if (!strcmp(res->value, "on")) {
+   rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
+   } else if (!strcmp(res->value, "off")) {
+   rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
+   } else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "rx-cksum")) {
if (!strcmp(res->value, "on"))
-   rx_mode.hw_ip_checksum = 1;
+   rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
else if (!strcmp(res->value, "off"))
-   rx_mode.hw_ip_checksum = 0;
+   rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "rx-timestamp")) {
if (!strcmp(res->value, "on"))
-   rx_mode.hw_timestamp = 1;
+   rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
else if (!strcmp(res->value, "off"))
-   rx_mode.hw_timestamp = 0;
+   rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
else {
printf("Unknown parameter\n");
return;
}
} else if (!strcmp(res->name, "hw-vlan")) {
if (!strcmp(res->value, "on")) {
-   rx_mode.hw_vlan_filter = 1;
-   rx_mode.hw_vlan_strip  = 1;
+   rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
+   DEV_RX_OFFLOAD_VLAN_STRIP);
}
else if (!strcmp(res->value, "off")) {
-   rx_mode.hw_vlan_filter = 0;
-   rx_mode.hw_vlan_strip  = 0;
+   rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
+   DEV_RX_OFFLOAD_VLAN_STRIP);
}
else {
printf("Unknow

[dpdk-dev] [PATCH v2 03/10] app/testpmd: support check of single port stop

2017-12-12 Thread Shahaf Shuler
This patch adds supports for checking if a single port is stopped.
currently there is a function to check only for all ports.

Signed-off-by: Shahaf Shuler 
---
 app/test-pmd/testpmd.c | 16 
 app/test-pmd/testpmd.h |  1 +
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 6785b09..77154ef 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1394,15 +1394,23 @@ static int eth_event_callback(portid_t port_id,
 }
 
 int
+port_is_stopped(portid_t port_id)
+{
+   struct rte_port *port = &ports[port_id];
+
+   if ((port->port_status != RTE_PORT_STOPPED) &&
+   (port->slave_flag == 0))
+   return 0;
+   return 1;
+}
+
+int
 all_ports_stopped(void)
 {
portid_t pi;
-   struct rte_port *port;
 
RTE_ETH_FOREACH_DEV(pi) {
-   port = &ports[pi];
-   if ((port->port_status != RTE_PORT_STOPPED) &&
-   (port->slave_flag == 0))
+   if (!port_is_stopped(pi))
return 0;
}
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 1639d27..ab74d39 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -682,6 +682,7 @@ int init_port_dcb_config(portid_t pid, enum dcb_mode_enable 
dcb_mode,
 void attach_port(char *identifier);
 void detach_port(portid_t port_id);
 int all_ports_stopped(void);
+int port_is_stopped(portid_t port_id);
 int port_is_started(portid_t port_id);
 void pmd_test_exit(void);
 void fdir_get_infos(portid_t port_id);
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 04/10] app/testpmd: convert to new Ethdev Tx offloads API

2017-12-12 Thread Shahaf Shuler
Ethdev Tx offloads API has changed since:

commit cba7f53b717d ("ethdev: introduce Tx queue offloads API")

Convert the application to use the new API.

This patch mandates the port to be stopped when configure the Tx
offloads. This is because the PMD must be aware to the offloads changes
on the device and queue configuration.

Signed-off-by: Shahaf Shuler 
---
 app/test-pmd/cmdline.c | 90 ++---
 app/test-pmd/config.c  | 55 ++-
 app/test-pmd/testpmd.c |  3 ++
 3 files changed, 124 insertions(+), 24 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index d8c73a9..5812583 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3439,7 +3439,14 @@ struct cmd_tx_vlan_set_result {
 {
struct cmd_tx_vlan_set_result *res = parsed_result;
 
+   if (!port_is_stopped(res->port_id)) {
+   printf("Please stop port %d first\n", res->port_id);
+   return;
+   }
+
tx_vlan_set(res->port_id, res->vlan_id);
+
+   cmd_reconfig_device_queue(res->port_id, 1, 1);
 }
 
 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
@@ -3486,7 +3493,14 @@ struct cmd_tx_vlan_set_qinq_result {
 {
struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
 
+   if (!port_is_stopped(res->port_id)) {
+   printf("Please stop port %d first\n", res->port_id);
+   return;
+   }
+
tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
+
+   cmd_reconfig_device_queue(res->port_id, 1, 1);
 }
 
 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
@@ -3592,7 +3606,14 @@ struct cmd_tx_vlan_reset_result {
 {
struct cmd_tx_vlan_reset_result *res = parsed_result;
 
+   if (!port_is_stopped(res->port_id)) {
+   printf("Please stop port %d first\n", res->port_id);
+   return;
+   }
+
tx_vlan_reset(res->port_id);
+
+   cmd_reconfig_device_queue(res->port_id, 1, 1);
 }
 
 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
@@ -3685,11 +3706,16 @@ struct cmd_csum_result {
struct cmd_csum_result *res = parsed_result;
int hw = 0;
uint16_t mask = 0;
+   uint64_t csum_offloads = 0;
 
if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
printf("invalid port %d\n", res->port_id);
return;
}
+   if (!port_is_stopped(res->port_id)) {
+   printf("Please stop port %d first\n", res->port_id);
+   return;
+   }
 
if (!strcmp(res->mode, "set")) {
 
@@ -3698,22 +3724,34 @@ struct cmd_csum_result {
 
if (!strcmp(res->proto, "ip")) {
mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
+   csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
} else if (!strcmp(res->proto, "udp")) {
mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
+   csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
} else if (!strcmp(res->proto, "tcp")) {
mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
+   csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
} else if (!strcmp(res->proto, "sctp")) {
mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
+   csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
} else if (!strcmp(res->proto, "outer-ip")) {
mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
+   csum_offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
}
 
-   if (hw)
+   if (hw) {
ports[res->port_id].tx_ol_flags |= mask;
-   else
+   ports[res->port_id].dev_conf.txmode.offloads |=
+   csum_offloads;
+   } else {
ports[res->port_id].tx_ol_flags &= (~mask);
+   ports[res->port_id].dev_conf.txmode.offloads &=
+   (~csum_offloads);
+   }
}
csum_show(res->port_id);
+
+   cmd_reconfig_device_queue(res->port_id, 1, 1);
 }
 
 cmdline_parse_token_string_t cmd_csum_csum =
@@ -3837,15 +3875,24 @@ struct cmd_tso_set_result {
 
if (port_id_is_invalid(res->port_id, ENABLED_WARN))
return;
+   if (!port_is_stopped(res->port_id)) {
+   printf("Please stop port %d first\n", res->port_id);
+   return;
+   }
 
if (!strcmp(res->mode, "set"))
ports[res->port_id].tso_segsz = res->tso_segsz;
 
-   if (ports[res->port_id].tso_segsz == 0)
+   if (ports[res->port_id].tso_segsz == 0) {
+   ports[res->port_id].dev_conf.txmode.offloads &=
+   ~DEV_TX_OFFLOAD_TCP_TSO;
printf("TSO for non-tunneled packets is disabled\

[dpdk-dev] [PATCH v2 05/10] app/testpmd: fix flowgen forwarding ol flags

2017-12-12 Thread Shahaf Shuler
The mbuf ol_flags were taken directly from testpmd internal enumeration
leading to incorrect values.

addressing only insertion offload flags as the checksum flags by
the application design are only with csum forwarding.

Fixes: e9e23a617eb8 ("app/testpmd: add flowgen forwarding engine")
Cc: cchempara...@tilera.com
Cc: sta...@dpdk.org

Signed-off-by: Shahaf Shuler 
---
 app/test-pmd/flowgen.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c
index acf9af9..46478fc 100644
--- a/app/test-pmd/flowgen.c
+++ b/app/test-pmd/flowgen.c
@@ -123,7 +123,7 @@
struct ipv4_hdr *ip_hdr;
struct udp_hdr *udp_hdr;
uint16_t vlan_tci, vlan_tci_outer;
-   uint16_t ol_flags;
+   uint64_t ol_flags;
uint16_t nb_rx;
uint16_t nb_tx;
uint16_t nb_pkt;
@@ -151,7 +151,13 @@
mbp = current_fwd_lcore()->mbp;
vlan_tci = ports[fs->tx_port].tx_vlan_id;
vlan_tci_outer = ports[fs->tx_port].tx_vlan_id_outer;
-   ol_flags = ports[fs->tx_port].tx_ol_flags;
+
+   if (ports[fs->tx_port].tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_VLAN)
+   ol_flags = PKT_TX_VLAN_PKT;
+   if (ports[fs->tx_port].tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_QINQ)
+   ol_flags |= PKT_TX_QINQ_PKT;
+   if (ports[fs->tx_port].tx_ol_flags & TESTPMD_TX_OFFLOAD_MACSEC)
+   ol_flags |= PKT_TX_MACSEC;
 
for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
pkt = rte_mbuf_raw_alloc(mbp);
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 07/10] app/testpmd: add command line option for Tx offloads

2017-12-12 Thread Shahaf Shuler
This patch adds command line option to set hex value for the ports Tx
offloads flags.

Signed-off-by: Shahaf Shuler 
---
 app/test-pmd/parameters.c | 17 +++--
 app/test-pmd/testpmd.c|  4 
 app/test-pmd/testpmd.h|  2 ++
 doc/guides/testpmd_app_ug/run_app.rst |  5 +
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 263651c..5888942 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -99,7 +99,7 @@
   "--rss-ip | --rss-udp | "
   "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
   "--txpt= | --txht= | --txwt= | --txfreet= | "
-  "--txrst= | --txqflags= ]\n",
+  "--txrst= | --txqflags= | --tx-offloads ]\n",
   progname);
 #ifdef RTE_LIBRTE_CMDLINE
printf("  --interactive: run in interactive mode.\n");
@@ -216,6 +216,7 @@
   "disable print of designated event or all of them.\n");
printf("  --flow-isolate-all: "
   "requests flow API isolated mode on all ports at initialization 
time.\n");
+   printf("  --tx-offloads=0x: hexadecimal bitmask of TX queue 
offloads\n");
 }
 
 #ifdef RTE_LIBRTE_CMDLINE
@@ -566,8 +567,9 @@
char **argvopt;
int opt_idx;
enum { TX, RX };
-   /* Default Rx offloads for all ports. */
+   /* Default offloads for all ports. */
uint64_t rx_offloads = rx_mode.offloads;
+   uint64_t tx_offloads = tx_mode.offloads;
 
static struct option lgopts[] = {
{ "help",   0, 0, 0 },
@@ -645,6 +647,7 @@
{ "no-rmv-interrupt",   0, 0, 0 },
{ "print-event",1, 0, 0 },
{ "mask-event", 1, 0, 0 },
+   { "tx-offloads",1, 0, 0 },
{ 0, 0, 0, 0 },
};
 
@@ -1116,6 +1119,15 @@
rmv_interrupt = 0;
if (!strcmp(lgopts[opt_idx].name, "flow-isolate-all"))
flow_isolate_all = 1;
+   if (!strcmp(lgopts[opt_idx].name, "tx-offloads")) {
+   char *end = NULL;
+   n = strtoull(optarg, &end, 16);
+   if (n >= 0)
+   tx_offloads = (uint64_t)n;
+   else
+   rte_exit(EXIT_FAILURE,
+"tx-offloads must be >= 0\n");
+   }
if (!strcmp(lgopts[opt_idx].name, "print-event"))
if (parse_event_printing_config(optarg, 1)) {
rte_exit(EXIT_FAILURE,
@@ -1142,4 +1154,5 @@
 
/* Set offload configuration from command line parameters. */
rx_mode.offloads = rx_offloads;
+   tx_mode.offloads = tx_offloads;
 }
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 0087438..8065481 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -344,6 +344,8 @@ struct rte_eth_rxmode rx_mode = {
.ignore_offload_bitfield = 1,
 };
 
+struct rte_eth_txmode tx_mode;
+
 struct rte_fdir_conf fdir_conf = {
.mode = RTE_FDIR_MODE_NONE,
.pballoc = RTE_FDIR_PBALLOC_64K,
@@ -604,6 +606,8 @@ static int eth_event_callback(portid_t port_id,
 
RTE_ETH_FOREACH_DEV(pid) {
port = &ports[pid];
+   /* Apply default Tx configuration for all ports */
+   port->dev_conf.txmode = tx_mode;
rte_eth_dev_info_get(pid, &port->dev_info);
 
if (numa_support) {
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index c6baa10..3e63edf 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -395,6 +395,8 @@ struct queue_stats_mappings {
 extern struct rte_port *ports;
 
 extern struct rte_eth_rxmode rx_mode;
+extern struct rte_eth_txmode tx_mode;
+
 extern uint64_t rss_hf;
 
 extern queueid_t nb_rxq;
diff --git a/doc/guides/testpmd_app_ug/run_app.rst 
b/doc/guides/testpmd_app_ug/run_app.rst
index 4c0d2ce..fface6f 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -509,3 +509,8 @@ The commandline options are:
 configured flow rules only (see flow command).
 
 Ports that do not support this mode are automatically discarded.
+
+*   ``--tx-offloads=0x``
+
+Set the hexadecimal bitmask of TX queue offloads.
+The default value is 0.
-- 
1.8.3.1



[dpdk-dev] [PATCH v2 06/10] app/testpmd: cleanup internal Tx offloads flags field

2017-12-12 Thread Shahaf Shuler
The tx_ol_flags field was used in order to control the different
Tx offloads set. After the conversion to the new Ethdev Tx offloads API
it is not needed anymore as the offloads configuration is stored in
ethdev structs.

Signed-off-by: Shahaf Shuler 
---
 app/test-pmd/cmdline.c  | 49 
 app/test-pmd/config.c   |  4 
 app/test-pmd/csumonly.c | 40 ++--
 app/test-pmd/flowgen.c  |  8 +---
 app/test-pmd/macfwd.c   |  8 +---
 app/test-pmd/macswap.c  |  8 +---
 app/test-pmd/testpmd.h  | 22 +---
 app/test-pmd/txonly.c   |  8 +---
 8 files changed, 59 insertions(+), 88 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 5812583..8584821 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3653,45 +3653,45 @@ struct cmd_csum_result {
 csum_show(int port_id)
 {
struct rte_eth_dev_info dev_info;
-   uint16_t ol_flags;
+   uint64_t tx_offloads;
 
-   ol_flags = ports[port_id].tx_ol_flags;
+   tx_offloads = ports[port_id].dev_conf.txmode.offloads;
printf("Parse tunnel is %s\n",
-   (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
+   (ports[port_id].parse_tunnel) ? "on" : "off");
printf("IP checksum offload is %s\n",
-   (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
+   (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
printf("UDP checksum offload is %s\n",
-   (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
+   (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
printf("TCP checksum offload is %s\n",
-   (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
+   (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
printf("SCTP checksum offload is %s\n",
-   (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
+   (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
printf("Outer-Ip checksum offload is %s\n",
-   (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
+   (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
 
/* display warnings if configuration is not supported by the NIC */
rte_eth_dev_info_get(port_id, &dev_info);
-   if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
+   if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
printf("Warning: hardware IP checksum enabled but not "
"supported by port %d\n", port_id);
}
-   if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
+   if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
printf("Warning: hardware UDP checksum enabled but not "
"supported by port %d\n", port_id);
}
-   if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
+   if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
printf("Warning: hardware TCP checksum enabled but not "
"supported by port %d\n", port_id);
}
-   if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
+   if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
printf("Warning: hardware SCTP checksum enabled but not "
"supported by port %d\n", port_id);
}
-   if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
+   if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 
0) {
printf("Warning: hardware outer IP checksum enabled but not "
"supported by port %d\n", port_id);
@@ -3705,7 +3705,6 @@ struct cmd_csum_result {
 {
struct cmd_csum_result *res = parsed_result;
int hw = 0;
-   uint16_t mask = 0;
uint64_t csum_offloads = 0;
 
if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
@@ -3723,28 +3722,21 @@ struct cmd_csum_result {
hw = 1;
 
if (!strcmp(res->proto, "ip")) {
-   mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
} else if (!strcmp(res->proto, "udp")) {
-   mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
} else if (!strcmp(res->proto, "tcp")) {
-   mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;

[dpdk-dev] [PATCH v2 08/10] app/testpmd: remove txqflags

2017-12-12 Thread Shahaf Shuler
Since testpmd is now using the new Ethdev offloads API and there is
a way configure each of the tx offloads from CLI or command line,
there is no need for the txqflags configuration anymore.

Signed-off-by: Shahaf Shuler 
Acked-by: Nelio Laranjeiro 
---
 app/test-pmd/cmdline.c  | 69 
 app/test-pmd/config.c   |  7 +--
 app/test-pmd/parameters.c   | 14 +
 app/test-pmd/testpmd.c  |  8 ---
 app/test-pmd/testpmd.h  |  1 -
 doc/guides/testpmd_app_ug/run_app.rst   | 12 -
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 
 7 files changed, 3 insertions(+), 119 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 8584821..b4ef1d0 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3092,74 +3092,6 @@ struct cmd_set_txsplit_result {
},
 };
 
-/* *** CONFIG TX QUEUE FLAGS *** */
-
-struct cmd_config_txqflags_result {
-   cmdline_fixed_string_t port;
-   cmdline_fixed_string_t config;
-   cmdline_fixed_string_t all;
-   cmdline_fixed_string_t what;
-   int32_t hexvalue;
-};
-
-static void cmd_config_txqflags_parsed(void *parsed_result,
-   __attribute__((unused)) struct cmdline *cl,
-   __attribute__((unused)) void *data)
-{
-   struct cmd_config_txqflags_result *res = parsed_result;
-
-   if (!all_ports_stopped()) {
-   printf("Please stop all ports first\n");
-   return;
-   }
-
-   if (strcmp(res->what, "txqflags")) {
-   printf("Unknown parameter\n");
-   return;
-   }
-
-   if (res->hexvalue >= 0) {
-   txq_flags = res->hexvalue;
-   } else {
-   printf("txqflags must be >= 0\n");
-   return;
-   }
-
-   init_port_config();
-
-   cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
-}
-
-cmdline_parse_token_string_t cmd_config_txqflags_port =
-   TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
-"port");
-cmdline_parse_token_string_t cmd_config_txqflags_config =
-   TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
-"config");
-cmdline_parse_token_string_t cmd_config_txqflags_all =
-   TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
-"all");
-cmdline_parse_token_string_t cmd_config_txqflags_what =
-   TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
-"txqflags");
-cmdline_parse_token_num_t cmd_config_txqflags_value =
-   TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
-   hexvalue, INT32);
-
-cmdline_parse_inst_t cmd_config_txqflags = {
-   .f = cmd_config_txqflags_parsed,
-   .data = NULL,
-   .help_str = "port config all txqflags ",
-   .tokens = {
-   (void *)&cmd_config_txqflags_port,
-   (void *)&cmd_config_txqflags_config,
-   (void *)&cmd_config_txqflags_all,
-   (void *)&cmd_config_txqflags_what,
-   (void *)&cmd_config_txqflags_value,
-   NULL,
-   },
-};
-
 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
 struct cmd_rx_vlan_filter_all_result {
cmdline_fixed_string_t rx_vlan;
@@ -15709,7 +15641,6 @@ struct cmd_cmdfile_result {
(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
(cmdline_parse_inst_t *)&cmd_config_rss,
(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
-   (cmdline_parse_inst_t *)&cmd_config_txqflags,
(cmdline_parse_inst_t *)&cmd_config_rss_reta,
(cmdline_parse_inst_t *)&cmd_showport_reta,
(cmdline_parse_inst_t *)&cmd_config_burst,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 57d73aa..41855ab 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -417,7 +417,6 @@ struct rss_type_info {
printf("\nTX writeback threshold: %hhu", qinfo.conf.tx_thresh.wthresh);
printf("\nTX RS threshold: %hu", qinfo.conf.tx_rs_thresh);
printf("\nTX free threshold: %hu", qinfo.conf.tx_free_thresh);
-   printf("\nTX flags: %#x", qinfo.conf.txq_flags);
printf("\nTX deferred start: %s",
(qinfo.conf.tx_deferred_start != 0) ? "on" : "off");
printf("\nNumber of TXDs: %hu", qinfo.nb_desc);
@@ -1713,10 +1712,8 @@ struct igb_ring_desc_16_bytes {
tx_conf->tx_thresh.pthresh,
tx_conf->tx_thresh.hthresh,
tx_conf->tx_thresh.wthresh);
-   printf("  TX RS bit threshold=%d - TXQ flags=0x%"PRIx32""
-  " - TXQ offloads=0x%"PRIx64"\n",
-   tx_conf->tx_rs_thresh, tx_conf->txq_flags,
-  

[dpdk-dev] [PATCH v2 09/10] app/testpmd: enforce offloads caps

2017-12-12 Thread Shahaf Shuler
In the current design it was possible for offload to be set even though
the device is not supporting it. A warning message was printed instead.

This is a wrong behaviour, as application should set only the offloads
reported by the capabilities of the device.

This patch adds verification for the offloads being set and make sure
the offload configuration passed to the device always match its
capabilities.

Signed-off-by: Shahaf Shuler 
---
 app/test-pmd/cmdline.c | 103 +---
 app/test-pmd/config.c  |  14 ++
 app/test-pmd/testpmd.c |  25 +++
 3 files changed, 117 insertions(+), 25 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b4ef1d0..d1b8dab 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3638,6 +3638,7 @@ struct cmd_csum_result {
struct cmd_csum_result *res = parsed_result;
int hw = 0;
uint64_t csum_offloads = 0;
+   struct rte_eth_dev_info dev_info;
 
if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
printf("invalid port %d\n", res->port_id);
@@ -3648,21 +3649,53 @@ struct cmd_csum_result {
return;
}
 
+   rte_eth_dev_info_get(res->port_id, &dev_info);
if (!strcmp(res->mode, "set")) {
 
if (!strcmp(res->hwsw, "hw"))
hw = 1;
 
if (!strcmp(res->proto, "ip")) {
-   csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
+   if (dev_info.tx_offload_capa &
+   DEV_TX_OFFLOAD_IPV4_CKSUM) {
+   csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
+   } else {
+   printf("IP checksum offload is not supported "
+  "by port %u\n", res->port_id);
+   }
} else if (!strcmp(res->proto, "udp")) {
-   csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
+   if (dev_info.tx_offload_capa &
+   DEV_TX_OFFLOAD_UDP_CKSUM) {
+   csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
+   } else {
+   printf("UDP checksum offload is not supported "
+  "by port %u\n", res->port_id);
+   }
} else if (!strcmp(res->proto, "tcp")) {
-   csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
+   if (dev_info.tx_offload_capa &
+   DEV_TX_OFFLOAD_TCP_CKSUM) {
+   csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
+   } else {
+   printf("TCP checksum offload is not supported "
+  "by port %u\n", res->port_id);
+   }
} else if (!strcmp(res->proto, "sctp")) {
-   csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
+   if (dev_info.tx_offload_capa &
+   DEV_TX_OFFLOAD_SCTP_CKSUM) {
+   csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
+   } else {
+   printf("SCTP checksum offload is not supported "
+  "by port %u\n", res->port_id);
+   }
} else if (!strcmp(res->proto, "outer-ip")) {
-   csum_offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+   if (dev_info.tx_offload_capa &
+   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
+   csum_offloads |=
+   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+   } else {
+   printf("Outer IP checksum offload is not "
+  "supported by port %u\n", res->port_id);
+   }
}
 
if (hw) {
@@ -3805,6 +3838,14 @@ struct cmd_tso_set_result {
if (!strcmp(res->mode, "set"))
ports[res->port_id].tso_segsz = res->tso_segsz;
 
+   rte_eth_dev_info_get(res->port_id, &dev_info);
+   if ((ports[res->port_id].tso_segsz != 0) &&
+   (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
+   printf("Error: TSO is not supported by port %d\n",
+  res->port_id);
+   return;
+   }
+
if (ports[res->port_id].tso_segsz == 0) {
ports[res->port_id].dev_conf.txmode.offloads &=
~DEV_TX_OFFLOAD_TCP_TSO;
@@ -3881,24 +3922,25 @@ struct cmd_tunnel_tso_set_result {
portid_t port_id;
 };
 
-static void
+static struct rte_eth_dev_info

[dpdk-dev] [PATCH v2 10/10] app/testpmd: fix on the flight VLAN configuration

2017-12-12 Thread Shahaf Shuler
On ethdev there is an API to configure VLAN offloads after the port
was started and without reconfiguration of the port or queues.

In the current design of the application, when the Rx offloads are
changed (through "port config all" CLI command) the port configuration
is overwritten, therefore the configuration made for the VLAN is lost.

This patch is to address the issue by a configuration of each port Rx
offloads separately instead of using the global Rx config.

Fixes: 6dbb2b336586 ("app/testpmd: convert to new Ethdev Rx offloads API")

Signed-off-by: Shahaf Shuler 
---
 app/test-pmd/cmdline.c | 217 +++-
 app/test-pmd/config.c  |  27 --
 app/test-pmd/testpmd.c |   2 +-
 3 files changed, 135 insertions(+), 111 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index d1b8dab..00a229a 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1577,34 +1577,38 @@ struct cmd_config_max_pkt_len_result {
__attribute__((unused)) void *data)
 {
struct cmd_config_max_pkt_len_result *res = parsed_result;
-   uint64_t rx_offloads = rx_mode.offloads;
+   portid_t pid;
 
if (!all_ports_stopped()) {
printf("Please stop all ports first\n");
return;
}
 
-   if (!strcmp(res->name, "max-pkt-len")) {
-   if (res->value < ETHER_MIN_LEN) {
-   printf("max-pkt-len can not be less than %d\n",
-   ETHER_MIN_LEN);
+   RTE_ETH_FOREACH_DEV(pid) {
+   struct rte_port *port = &ports[pid];
+   uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
+
+   if (!strcmp(res->name, "max-pkt-len")) {
+   if (res->value < ETHER_MIN_LEN) {
+   printf("max-pkt-len can not be less than %d\n",
+   ETHER_MIN_LEN);
+   return;
+   }
+   if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
+   return;
+
+   port->dev_conf.rxmode.max_rx_pkt_len = res->value;
+   if (res->value > ETHER_MAX_LEN)
+   rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+   else
+   rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
+   port->dev_conf.rxmode.offloads = rx_offloads;
+   } else {
+   printf("Unknown parameter\n");
return;
}
-   if (res->value == rx_mode.max_rx_pkt_len)
-   return;
-
-   rx_mode.max_rx_pkt_len = res->value;
-   if (res->value > ETHER_MAX_LEN)
-   rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
-   else
-   rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
-   } else {
-   printf("Unknown parameter\n");
-   return;
}
 
-   rx_mode.offloads = rx_offloads;
-
init_port_config();
 
cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
@@ -1706,103 +1710,108 @@ struct cmd_config_rx_mode_flag {
__attribute__((unused)) void *data)
 {
struct cmd_config_rx_mode_flag *res = parsed_result;
-   uint64_t rx_offloads = rx_mode.offloads;
+   portid_t pid;
 
if (!all_ports_stopped()) {
printf("Please stop all ports first\n");
return;
}
 
-   if (!strcmp(res->name, "crc-strip")) {
-   if (!strcmp(res->value, "on"))
-   rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
-   else if (!strcmp(res->value, "off"))
-   rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
-   else {
-   printf("Unknown parameter\n");
-   return;
-   }
-   } else if (!strcmp(res->name, "scatter")) {
-   if (!strcmp(res->value, "on")) {
-   rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
-   } else if (!strcmp(res->value, "off")) {
-   rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
+   RTE_ETH_FOREACH_DEV(pid) {
+   struct rte_port *port;
+   uint64_t rx_offloads;
+
+   port = &ports[pid];
+   rx_offloads = port->dev_conf.rxmode.offloads;
+   if (!strcmp(res->name, "crc-strip")) {
+   if (!strcmp(res->value, "on"))
+   rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
+   else if (!strcmp(res->value, "off"))
+   rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
+   else {
+   printf("Unknown parameter\n");
+  

[dpdk-dev] [PATCH 2/3] net/ixgbe: implemented security session get size

2017-12-12 Thread Radu Nicolau
Signed-off-by: Radu Nicolau 
---
 drivers/net/ixgbe/ixgbe_ipsec.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ipsec.c b/drivers/net/ixgbe/ixgbe_ipsec.c
index 105da11..720d6a1 100644
--- a/drivers/net/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ixgbe/ixgbe_ipsec.c
@@ -446,6 +446,12 @@ ixgbe_crypto_create_session(void *device,
 }
 
 static int
+ixgbe_crypto_session_get_size(__rte_unused void *device)
+{
+   return sizeof(struct ixgbe_crypto_session);
+}
+
+static int
 ixgbe_crypto_remove_session(void *device,
struct rte_security_session *session)
 {
@@ -717,6 +723,7 @@ ixgbe_crypto_add_ingress_sa_from_flow(const void *sess,
 static struct rte_security_ops ixgbe_security_ops = {
.session_create = ixgbe_crypto_create_session,
.session_update = NULL,
+   .session_get_size = ixgbe_crypto_session_get_size,
.session_stats_get = NULL,
.session_destroy = ixgbe_crypto_remove_session,
.set_pkt_metadata = ixgbe_crypto_update_mb,
-- 
2.7.5



[dpdk-dev] [PATCH 1/3] lib/librte_security: added get size

2017-12-12 Thread Radu Nicolau
Signed-off-by: Radu Nicolau 
---
 lib/librte_security/rte_security.c   |  7 +++
 lib/librte_security/rte_security.h   | 12 
 lib/librte_security/rte_security_driver.h| 14 ++
 lib/librte_security/rte_security_version.map |  1 +
 4 files changed, 34 insertions(+)

diff --git a/lib/librte_security/rte_security.c 
b/lib/librte_security/rte_security.c
index 1227fca..56f2345 100644
--- a/lib/librte_security/rte_security.c
+++ b/lib/librte_security/rte_security.c
@@ -70,6 +70,13 @@ rte_security_session_update(struct rte_security_ctx 
*instance,
return instance->ops->session_update(instance->device, sess, conf);
 }
 
+unsigned int
+rte_security_session_get_size(struct rte_security_ctx *instance)
+{
+   RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->session_get_size, 0);
+   return instance->ops->session_get_size(instance->device);
+}
+
 int
 rte_security_session_stats_get(struct rte_security_ctx *instance,
   struct rte_security_session *sess,
diff --git a/lib/librte_security/rte_security.h 
b/lib/librte_security/rte_security.h
index 653929b..2c5429f 100644
--- a/lib/librte_security/rte_security.h
+++ b/lib/librte_security/rte_security.h
@@ -312,6 +312,18 @@ rte_security_session_update(struct rte_security_ctx 
*instance,
struct rte_security_session_conf *conf);
 
 /**
+ * Get the size of the security session data for a device.
+ *
+ * @param   instance   security instance.
+ *
+ * @return
+ *   - Size of the private data, if successful
+ *   - 0 if device is invalid or does not support the operation.
+ */
+unsigned int
+rte_security_session_get_size(struct rte_security_ctx *instance);
+
+/**
  * Free security session header and the session private data and
  * return it to its original mempool.
  *
diff --git a/lib/librte_security/rte_security_driver.h 
b/lib/librte_security/rte_security_driver.h
index 997fbe7..3839d45 100644
--- a/lib/librte_security/rte_security_driver.h
+++ b/lib/librte_security/rte_security_driver.h
@@ -91,6 +91,18 @@ typedef int (*security_session_destroy_t)(void *device,
 typedef int (*security_session_update_t)(void *device,
struct rte_security_session *sess,
struct rte_security_session_conf *conf);
+
+/**
+ * Get the size of a security session
+ *
+ * @param  device  Crypto/eth device pointer
+ *
+ * @return
+ *  - On success returns the size of the session structure for device
+ *  - On failure returns 0
+ */
+typedef int (*security_session_get_size)(void *device);
+
 /**
  * Get stats from the PMD.
  *
@@ -139,6 +151,8 @@ struct rte_security_ops {
/**< Configure a security session. */
security_session_update_t session_update;
/**< Update a security session. */
+   security_session_get_size session_get_size;
+   /**< Return size of security session. */
security_session_stats_get_t session_stats_get;
/**< Get security session statistics. */
security_session_destroy_t session_destroy;
diff --git a/lib/librte_security/rte_security_version.map 
b/lib/librte_security/rte_security_version.map
index e12c04b..2f74568 100644
--- a/lib/librte_security/rte_security_version.map
+++ b/lib/librte_security/rte_security_version.map
@@ -6,6 +6,7 @@ EXPERIMENTAL {
rte_security_capability_get;
rte_security_session_create;
rte_security_session_destroy;
+   rte_security_session_get_size;
rte_security_session_stats_get;
rte_security_session_update;
rte_security_set_pkt_metadata;
-- 
2.7.5



[dpdk-dev] [PATCH 3/3] examples/ipsec_secgw: create session mempools for ethdevs

2017-12-12 Thread Radu Nicolau
Also moved offloaded packets from cryptodev queues

Signed-off-by: Radu Nicolau 
---
 examples/ipsec-secgw/ipsec-secgw.c | 42 +-
 examples/ipsec-secgw/ipsec.c   | 31 ++--
 examples/ipsec-secgw/ipsec.h   |  4 ++--
 3 files changed, 58 insertions(+), 19 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c 
b/examples/ipsec-secgw/ipsec-secgw.c
index c98454a..08d5b5a 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -1244,7 +1244,7 @@ cryptodevs_init(void)
struct rte_cryptodev_config dev_conf;
struct rte_cryptodev_qp_conf qp_conf;
uint16_t idx, max_nb_qps, qp, i;
-   int16_t cdev_id;
+   int16_t cdev_id, port_id;
struct rte_hash_parameters params = { 0 };
 
params.entries = CDEV_MAP_ENTRIES;
@@ -1273,6 +1273,14 @@ cryptodevs_init(void)
if (sess_sz > max_sess_sz)
max_sess_sz = sess_sz;
}
+   for (port_id = 0; port_id < rte_eth_dev_count(); port_id++) {
+   if ((enabled_port_mask & (1 << port_id)) == 0)
+   continue;
+   sess_sz = rte_security_session_get_size(
+   rte_eth_dev_get_sec_ctx(port_id));
+   if (sess_sz > max_sess_sz)
+   max_sess_sz = sess_sz;
+   }
 
idx = 0;
/* Start from last cdev id to give HW priority */
@@ -1343,6 +1351,38 @@ cryptodevs_init(void)
cdev_id);
}
 
+   /* create session pools for eth devices that implement security */
+   for (port_id = 0; port_id < rte_eth_dev_count(); port_id++) {
+   if ((enabled_port_mask & (1 << port_id)) &&
+   rte_eth_dev_get_sec_ctx(port_id)) {
+   int socket_id = rte_eth_dev_socket_id(port_id);
+
+   if (!socket_ctx[socket_id].session_pool) {
+   char mp_name[RTE_MEMPOOL_NAMESIZE];
+   struct rte_mempool *sess_mp;
+
+   snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
+   "sess_mp_%u", socket_id);
+   sess_mp = rte_mempool_create(mp_name,
+   CDEV_MP_NB_OBJS,
+   max_sess_sz,
+   CDEV_MP_CACHE_SZ,
+   0, NULL, NULL, NULL,
+   NULL, socket_id,
+   0);
+   if (sess_mp == NULL)
+   rte_exit(EXIT_FAILURE,
+   "Cannot create session pool "
+   "on socket %d\n", socket_id);
+   else
+   printf("Allocated session pool "
+   "on socket %d\n", socket_id);
+   socket_ctx[socket_id].session_pool = sess_mp;
+   }
+   }
+   }
+
+
printf("\n");
 
return 0;
diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 70ed227..708f29e 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -266,7 +266,6 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx 
*ipsec_ctx,
struct ipsec_mbuf_metadata *priv;
struct rte_crypto_sym_op *sym_cop;
struct ipsec_sa *sa;
-   struct cdev_qp *cqp;
 
for (i = 0; i < nb_pkts; i++) {
if (unlikely(sas[i] == NULL)) {
@@ -345,8 +344,7 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx 
*ipsec_ctx,
continue;
}
 
-   cqp = &ipsec_ctx->tbl[sa->cdev_id_qp];
-   cqp->ol_pkts[cqp->ol_pkts_cnt++] = pkts[i];
+   ipsec_ctx->ol_pkts[ipsec_ctx->ol_pkts_cnt++] = pkts[i];
if (sa->ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA)
rte_security_set_pkt_metadata(
sa->security_ctx,
@@ -369,6 +367,20 @@ ipsec_dequeue(ipsec_xform_fn xform_func, struct ipsec_ctx 
*ipsec_ctx,
struct ipsec_sa *sa;
struct rte_mbuf *pkt;
 
+   while (ipsec_ctx->ol_pkts_cnt > 0 && nb_pkts < max_pkts) {
+   pkt = ipsec_ctx->ol_pkts[--ipsec_ctx->ol_pkts_cnt];
+   rte_prefetch0(pkt);
+   priv = get_priv(pkt);
+   sa = priv->sa;
+   ret = xform_func(pkt, sa, &priv->cop);
+   if (unlikely(ret)) {
+   rte_pktmbuf_free(pkt);
+   continu

Re: [dpdk-dev] [PATCH v3] doc: add a restriction to multi-process support

2017-12-12 Thread Chen, Junjie J
Done!

Cheers
JJ

> -Original Message-
> From: Mcnamara, John
> Sent: Tuesday, December 12, 2017 8:41 PM
> To: Chen, Junjie J ; Gonzalez Monroy, Sergio
> ; Tahhan, Maryam
> ; dev@dpdk.org
> Subject: RE: [PATCH v3] doc: add a restriction to multi-process support
> 
> 
> 
> > -Original Message-
> > From: Chen, Junjie J
> > Sent: Wednesday, November 29, 2017 5:17 PM
> > To: Gonzalez Monroy, Sergio ;
> > Mcnamara, John ; Tahhan, Maryam
> > ; dev@dpdk.org
> > Cc: Chen, Junjie J 
> > Subject: [PATCH v3] doc: add a restriction to multi-process support
> >
> > This patch add a restriction to multi-process support: secondary
> > processes should only run alongside primary process with same DPDK
> > version, so that secondary processes can use the same hugepage mmap
> > layout as primary process.
> >
> > Signed-off-by: Junjie Chen 
> 
> Could you mark the previous version of this patch as "Superseded":
> 
> http://dpdk.org/dev/patchwork/project/dpdk/list/?submitter=&state=&q=restri
> ction+to+multi-process+support&archive=&delegate=
> 
> 
> Otherwise:
> 
> Acked-by: John McNamara 
> 



Re: [dpdk-dev] [PATCH 1/3] ethdev: add max burst size to device info

2017-12-12 Thread Shreyansh Jain

On Tuesday 12 December 2017 04:33 PM, Ananyev, Konstantin wrote:




-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Matan Azrad
Sent: Tuesday, December 12, 2017 10:46 AM
To: Nikhil Agarwal ; dev@dpdk.org
Cc: Hunt, David ; nikhil.agar...@nxp.com; 
hemant.agra...@nxp.com; Yigit, Ferruh 
Subject: Re: [dpdk-dev] [PATCH 1/3] ethdev: add max burst size to device info

Hi Nikhil


-Original Message-
From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Nikhil Agarwal
Sent: Tuesday, December 12, 2017 12:05 PM
To: dev@dpdk.org
Cc: david.h...@intel.com; nikhil.agar...@nxp.com;
hemant.agra...@nxp.com; ferruh.yi...@intel.com
Subject: [dpdk-dev] [PATCH 1/3] ethdev: add max burst size to device info

Currently, if the  rte_eth_rx_burst() function returns a value less than
*nb_pkts*, the application will assume that no more packets are present..

Some of the hw queue based hardware can only support smaller burst for RX
and TX and thus break the expectation of the rx_burst API.



Doesn't such like devices PMDs should try to retrieve multiple HW burst to 
adjust the asked received  packet number?


Same thought here...
Can't that limitation be hidden inside PMD by calling HW burst multiple times?


This might be required in some cases for performance.
It is possible that for each request containing N buffers, if the PMD 
fetches all N (more than its preferred burst_size), cache misses reduce 
the performance - especially for SoC with limited cache size.


Also, a complete cycle of 
application->driver->hardware->driver->application can help driver 
prefetch buffers - which, in case of hw burst looping, might be too 
little to complete the prefetch cycle.


To summarize, indeed this is for performance specific cases and the idea 
that @Matan gave for renaming 'perf_buf_size' to highlight this, sounds 
logical.



Also if I am not mistaken - it would increase size of struct rte_eth_dev_info, 
right?
If so, then it means ABI breakage.


Yes, deprecation notice should have been sent - if we continue with the 
dev_info change. To me that looks as one of the option. Maybe, someone 
on the list has a better idea.



Konstantin




This patch adds support to provide the maximum burst size that can be
supported by a given PMD. The dev_info is being memset to '0' in
rte_ethdev library. The value of '0' indicates that any value for burst size can
be supported i.e. no change for existing PMDs.

The application can now use the lowest available max_burst_size value for
rte_eth_rx_burst.



If you are talking about performance, maybe the right field to expose is something like 
"perf_burst_size" or "preferred_burst_size".
I also suggest to expose different fields for RX and for TX.
Maybe the rte_eth_rx\tx_burst() descriptions should be updated.

Thanks
Matan.


Signed-off-by: Nikhil Agarwal 
---
  lib/librte_ether/rte_ethdev.h | 1 +
  1 file changed, 1 insertion(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 341c2d6..3ab6f02 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1047,6 +1047,7 @@ struct rte_eth_dev_info {
/** Configured number of rx/tx queues */
uint16_t nb_rx_queues; /**< Number of RX queues. */
uint16_t nb_tx_queues; /**< Number of TX queues. */
+   uint16_t max_burst_size; /**< MAX burst size, 0 for no limit. */
  };

  /**
--
2.7.4







Re: [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: add target queues in flow actions

2017-12-12 Thread Nelio Laranjeiro
Hi Anoob,

On Tue, Dec 12, 2017 at 06:13:08PM +0530, Anoob Joseph wrote:
> Hi Nelio,
> 
> 
> On 12/11/2017 07:34 PM, Nelio Laranjeiro wrote:
> > Mellanox INNOVA NIC needs to have final target queue actions to perform
> > inline crypto.
> > 
> > Signed-off-by: Nelio Laranjeiro 
> > 
> > ---
> > 
> > Changes in v3:
> > 
> >   * removed PASSTHRU test for ingress.
> >   * removed check on configured queues for the queue action.
> > 
> > Changes in v2:
> > 
> >   * Test the rule by PASSTHRU/RSS/QUEUE and apply the first one validated.
> > ---
> >   examples/ipsec-secgw/ipsec.c | 57 
> > ++--
> >   examples/ipsec-secgw/ipsec.h |  2 +-
> >   2 files changed, 56 insertions(+), 3 deletions(-)
> > 
> > diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
> > index 17bd7620d..1b8b251c8 100644
> > --- a/examples/ipsec-secgw/ipsec.c
> > +++ b/examples/ipsec-secgw/ipsec.c
> > @@ -142,6 +142,7 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct 
> > ipsec_sa *sa)
> > rte_eth_dev_get_sec_ctx(
> > sa->portid);
> > const struct rte_security_capability *sec_cap;
> > +   int ret = 0;
> > sa->sec_session = rte_security_session_create(ctx,
> > &sess_conf, ipsec_ctx->session_pool);
> > @@ -201,15 +202,67 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct 
> > ipsec_sa *sa)
> > sa->action[0].type = RTE_FLOW_ACTION_TYPE_SECURITY;
> > sa->action[0].conf = sa->sec_session;
> > -   sa->action[1].type = RTE_FLOW_ACTION_TYPE_END;
> > -
> > sa->attr.egress = (sa->direction ==
> > RTE_SECURITY_IPSEC_SA_DIR_EGRESS);
> > sa->attr.ingress = (sa->direction ==
> > RTE_SECURITY_IPSEC_SA_DIR_INGRESS);
> > +   if (sa->attr.ingress) {
> > +   uint8_t rss_key[40];
> > +   struct rte_eth_rss_conf rss_conf = {
> > +   .rss_key = rss_key,
> > +   .rss_key_len = 40,
> > +   };
> > +   struct rte_eth_dev *eth_dev;
> > +   union {
> > +   struct rte_flow_action_rss rss;
> > +   struct {
> > +   const struct rte_eth_rss_conf *rss_conf;
> > +   uint16_t num;
> > +   uint16_t queue[RTE_MAX_QUEUES_PER_PORT];
> > +   } local;
> > +   } action_rss;
> > +   unsigned int i;
> > +   unsigned int j;
> > +
> > +   sa->action[2].type = RTE_FLOW_ACTION_TYPE_END;
> > +   /* Try RSS. */
> > +   sa->action[1].type = RTE_FLOW_ACTION_TYPE_RSS;
> > +   sa->action[1].conf = &action_rss;
> > +   eth_dev = ctx->device;
> > +   rte_eth_dev_rss_hash_conf_get(sa->portid,
> > + &rss_conf);
> > +   for (i = 0, j = 0;
> > +i < eth_dev->data->nb_rx_queues; ++i)
> > +   if (eth_dev->data->rx_queues[i])
> > +   action_rss.local.queue[j++] = i;
> > +   action_rss.local.num = j;
> > +   action_rss.local.rss_conf = &rss_conf;
> > +   ret = rte_flow_validate(sa->portid, &sa->attr,
> > +   sa->pattern, sa->action,
> > +   &err);
> > +   if (!ret)
> > +   goto flow_create;
> > +   /* Try Queue. */
> > +   sa->action[1].type = RTE_FLOW_ACTION_TYPE_QUEUE;
> > +   sa->action[1].conf =
> > +   &(struct rte_flow_action_queue){
> > +   .index = 0,
> > +   };
> > +   ret = rte_flow_validate(sa->portid, &sa->attr,
> > +   sa->pattern, sa->action,
> > +   &err);
> > +   if (ret)
> > +   goto flow_create_failure;
> > +   } else {
> > +   sa->action[1].type =
> > +   RTE_FLOW_ACTION_

Re: [dpdk-dev] [PATCH v3 1/2] lib/security: add support for get metadata

2017-12-12 Thread Anoob Joseph

Hi Akhil, Radu


On 12/12/2017 02:25 PM, Akhil Goyal wrote:

Hi Anoob,

On 12/11/2017 12:51 PM, Anoob wrote:

Hi Akhil,

Can you confirm if you are fine with the approach explained inline.

Thanks,
Anoob

On 12/06/2017 03:13 PM, Radu Nicolau wrote:

Hi,


On 12/6/2017 7:30 AM, Anoob wrote:

Hi Akhil, Radu,

Please see inline.

Thanks,

Anoob


On 11/24/2017 05:33 PM, Akhil Goyal wrote:

On 11/24/2017 5:29 PM, Radu Nicolau wrote:



On 11/24/2017 11:34 AM, Akhil Goyal wrote:

Hi Radu,
On 11/24/2017 4:47 PM, Radu Nicolau wrote:



On 11/24/2017 10:55 AM, Akhil Goyal wrote:

On 11/24/2017 3:09 PM, Radu Nicolau wrote:

Hi,

Comment inline


On 11/24/2017 8:50 AM, Akhil Goyal wrote:

Hi Anoob, Radu,
On 11/23/2017 4:49 PM, Anoob Joseph wrote:
In case of inline protocol processed ingress traffic, the 
packet may not
have enough information to determine the security 
parameters with which
the packet was processed. In such cases, application could 
get metadata
from the packet which could be used to identify the 
security parameters

with which the packet was processed.

Signed-off-by: Anoob Joseph 
---
v3:
* Replaced 64 bit metadata in conf with (void *)userdata
* The API(rte_security_get_pkt_metadata) would return void 
* instead of

   uint64_t

v2:
* Replaced get_session and get_cookie APIs with 
get_pkt_metadata API


  lib/librte_security/rte_security.c | 13 +
  lib/librte_security/rte_security.h | 19 +++
  lib/librte_security/rte_security_driver.h | 16 


  3 files changed, 48 insertions(+)

diff --git a/lib/librte_security/rte_security.c 
b/lib/librte_security/rte_security.c

index 1227fca..a1d78b6 100644
--- a/lib/librte_security/rte_security.c
+++ b/lib/librte_security/rte_security.c
@@ -108,6 +108,19 @@ rte_security_set_pkt_metadata(struct 
rte_security_ctx *instance,

 sess, m, params);
  }
  +void *
+rte_security_get_pkt_metadata(struct rte_security_ctx 
*instance,

+  struct rte_mbuf *pkt)
Can we rename pkt with m. Just to make it consistent with 
the set API.

+{
+    void *md = NULL;
+
+ RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->get_pkt_metadata, 
NULL);
+    if (instance->ops->get_pkt_metadata(instance->device, 
pkt, &md))

+    return NULL;
+
+    return md;
+}


Pkt metadata should be set by user i.e. the application, and 
the driver need not be aware of the format and the values of 
the metadata.
So setting the metadata in the driver and getting it back 
from the driver does not look a good idea.


Is it possible, that the application define the metadata on 
its own and set it in the library itself without the call to 
the driver ops.
I'm not sure I understand here; even in our case (ixgbe) the 
driver sets the metadata and it is aware of the format - that 
is the whole idea. This is why we added the set_metadata API, 
to allow the driver to inject extra information into the 
mbuf, information that is driver specific and derived from 
the security session, so it makes sense to also have a 
symmetric get_metadata.
Private data is the one that follows those rules, i.e. 
application specific and driver transparent.


As per my understanding of the user metadata, it should be in 
control of the application, and the application shall know the 
format of that. Setting in driver will disallow this.

Please let me know if my understanding is incorrect.

If at all, some information is needed to be set on the basis 
of driver, then application can get that information from the 
driver and then set it in the packet metadata in its own 
way/format.


The rte_security_set_pkt_metadata() doc defines the metadata as 
"device-specific defined metadata" and also takes a device 
specific params pointer, so the symmetric function is to be 
expected to work in the same way, i.e. return device specific 
metadata associated with the security session and instance and 
mbuf. How is this metadata stored is not specified in the 
security API, so the PMD implementation have the flexibility.
Is rte_security_get_pkt_metadata() expected to return a "device 
specific" pointer? If that's the case, we would need another call 
(something like, rte_security_get_userdata()) to get back the 
userdata, right? Or is it fine, if the application assumes it will 
get userdata (the one passed in conf while creating security 
session) with rte_security_get_pkt_metadata()?
Yes, this will be my assumption, a "device specific" pointer 
(similar to the "void *params" parameter of the 
rte_security_set_pkt_metadata function), which will contain an 
arbitrary defined structure that will be decoded by calling a PMD 
defined function.

But I think Akhil has a different view on this.
I am ok with the approach, if we are adding this as a limitation of 
using udata in the documentation for inline cases.


The ideal approach should be such that driver should not be knowing 
the content of the udata. But, if we cannot do away with it, we can 
mention it in the d

[dpdk-dev] [PATCH v3 1/4] power: changed unsigned to unsigned int

2017-12-12 Thread Marko Kovacevic
Since this patch-set attempts to clean up the power library,
and there are many instances of "unsigned" caught by checkpatch,
it was decided to clean these up first rather than have them included
in the later patches in the patch set. And would also minimise this
type of error being caught by checkpatch in the future

Signed-off-by: Marko Kovacevic 

Acked-By: David Hunt 

---
 lib/librte_power/guest_channel.c  |  6 +++---
 lib/librte_power/guest_channel.h  |  6 +++---
 lib/librte_power/rte_power.c  |  4 ++--
 lib/librte_power/rte_power.h  | 12 ++--
 lib/librte_power/rte_power_acpi_cpufreq.c | 16 
 lib/librte_power/rte_power_kvm_vm.c   | 20 ++--
 lib/librte_power/rte_power_kvm_vm.h   | 18 +-
 7 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/lib/librte_power/guest_channel.c b/lib/librte_power/guest_channel.c
index fa5de0f..e7ffc80 100644
--- a/lib/librte_power/guest_channel.c
+++ b/lib/librte_power/guest_channel.c
@@ -51,7 +51,7 @@
 static int global_fds[RTE_MAX_LCORE];
 
 int
-guest_channel_host_connect(const char *path, unsigned lcore_id)
+guest_channel_host_connect(const char *path, unsigned int lcore_id)
 {
int flags, ret;
struct channel_packet pkt;
@@ -118,7 +118,7 @@ guest_channel_host_connect(const char *path, unsigned 
lcore_id)
 }
 
 int
-guest_channel_send_msg(struct channel_packet *pkt, unsigned lcore_id)
+guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id)
 {
int ret, buffer_len = sizeof(*pkt);
void *buffer = pkt;
@@ -156,7 +156,7 @@ int rte_power_guest_channel_send_msg(struct channel_packet 
*pkt,
 
 
 void
-guest_channel_host_disconnect(unsigned lcore_id)
+guest_channel_host_disconnect(unsigned int lcore_id)
 {
if (lcore_id >= RTE_MAX_LCORE) {
RTE_LOG(ERR, GUEST_CHANNEL, "Channel(%u) is out of range 
0...%d\n",
diff --git a/lib/librte_power/guest_channel.h b/lib/librte_power/guest_channel.h
index 741339c..12c2587 100644
--- a/lib/librte_power/guest_channel.h
+++ b/lib/librte_power/guest_channel.h
@@ -53,7 +53,7 @@ extern "C" {
  *  - 0 on success.
  *  - Negative on error.
  */
-int guest_channel_host_connect(const char *path, unsigned lcore_id);
+int guest_channel_host_connect(const char *path, unsigned int lcore_id);
 
 /**
  * Disconnect from an already connected Virtio-Serial Endpoint.
@@ -63,7 +63,7 @@ int guest_channel_host_connect(const char *path, unsigned 
lcore_id);
  *  lcore_id.
  *
  */
-void guest_channel_host_disconnect(unsigned lcore_id);
+void guest_channel_host_disconnect(unsigned int lcore_id);
 
 /**
  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
@@ -79,7 +79,7 @@ void guest_channel_host_disconnect(unsigned lcore_id);
  *  - Negative on channel not connected.
  *  - errno on write to channel error.
  */
-int guest_channel_send_msg(struct channel_packet *pkt, unsigned lcore_id);
+int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id);
 
 /**
  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
diff --git a/lib/librte_power/rte_power.c b/lib/librte_power/rte_power.c
index b327a86..e7f35cf 100644
--- a/lib/librte_power/rte_power.c
+++ b/lib/librte_power/rte_power.c
@@ -106,7 +106,7 @@ rte_power_get_env(void) {
 }
 
 int
-rte_power_init(unsigned lcore_id)
+rte_power_init(unsigned int lcore_id)
 {
int ret = -1;
 
@@ -138,7 +138,7 @@ rte_power_init(unsigned lcore_id)
 }
 
 int
-rte_power_exit(unsigned lcore_id)
+rte_power_exit(unsigned int lcore_id)
 {
if (global_default_env == PM_ENV_ACPI_CPUFREQ)
return rte_power_acpi_cpufreq_exit(lcore_id);
diff --git a/lib/librte_power/rte_power.h b/lib/librte_power/rte_power.h
index b17b7a5..9b54039 100644
--- a/lib/librte_power/rte_power.h
+++ b/lib/librte_power/rte_power.h
@@ -91,7 +91,7 @@ enum power_management_env rte_power_get_env(void);
  *  - 0 on success.
  *  - Negative on error.
  */
-int rte_power_init(unsigned lcore_id);
+int rte_power_init(unsigned int lcore_id);
 
 /**
  * Exit power management on a specific lcore. This will call the environment
@@ -104,7 +104,7 @@ int rte_power_init(unsigned lcore_id);
  *  - 0 on success.
  *  - Negative on error.
  */
-int rte_power_exit(unsigned lcore_id);
+int rte_power_exit(unsigned int lcore_id);
 
 /**
  * Get the available frequencies of a specific lcore.
@@ -121,7 +121,7 @@ int rte_power_exit(unsigned lcore_id);
  * @return
  *  The number of available frequencies.
  */
-typedef uint32_t (*rte_power_freqs_t)(unsigned lcore_id, uint32_t *freqs,
+typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs,
uint32_t num);
 
 extern rte_power_freqs_t rte_power_freqs;
@@ -137,7 +137,7 @@ extern rte_power_freqs_t rte_power_freqs;
  * @return
  *  The current index of available frequencies.
  */
-typedef uint32_t (*rte_power_get_freq_t)(unsigned lcor

[dpdk-dev] [PATCH v3 2/4] power: clean up of power common header

2017-12-12 Thread Marko Kovacevic
Rename private header file rte_power_common.h
to power_common.h to prevent private functions
from leaking into the documentation.

Signed-off-by: Marko Kovacevic 

Acked-By: David Hunt 

---
 lib/librte_power/{rte_power_common.h => power_common.h} | 6 +++---
 lib/librte_power/rte_power.c| 2 +-
 lib/librte_power/rte_power_acpi_cpufreq.c   | 2 +-
 lib/librte_power/rte_power_kvm_vm.c | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
 rename lib/librte_power/{rte_power_common.h => power_common.h} (95%)

diff --git a/lib/librte_power/rte_power_common.h 
b/lib/librte_power/power_common.h
similarity index 95%
rename from lib/librte_power/rte_power_common.h
rename to lib/librte_power/power_common.h
index 64bd168..43e6564 100644
--- a/lib/librte_power/rte_power_common.h
+++ b/lib/librte_power/power_common.h
@@ -31,9 +31,9 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef RTE_POWER_COMMON_H_
-#define RTE_POWER_COMMON_H_
+#ifndef _POWER_COMMON_H_
+#define _POWER_COMMON_H_
 
 #define RTE_POWER_INVALID_FREQ_INDEX (~0)
 
-#endif /* RTE_POWER_COMMON_H_ */
+#endif /* _POWER_COMMON_H_ */
diff --git a/lib/librte_power/rte_power.c b/lib/librte_power/rte_power.c
index e7f35cf..c363667 100644
--- a/lib/librte_power/rte_power.c
+++ b/lib/librte_power/rte_power.c
@@ -36,7 +36,7 @@
 #include "rte_power.h"
 #include "rte_power_acpi_cpufreq.h"
 #include "rte_power_kvm_vm.h"
-#include "rte_power_common.h"
+#include "power_common.h"
 
 enum power_management_env global_default_env = PM_ENV_NOT_SET;
 
diff --git a/lib/librte_power/rte_power_acpi_cpufreq.c 
b/lib/librte_power/rte_power_acpi_cpufreq.c
index 618bf45..755dfff 100644
--- a/lib/librte_power/rte_power_acpi_cpufreq.c
+++ b/lib/librte_power/rte_power_acpi_cpufreq.c
@@ -45,7 +45,7 @@
 #include 
 
 #include "rte_power_acpi_cpufreq.h"
-#include "rte_power_common.h"
+#include "power_common.h"
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
 #define POWER_DEBUG_TRACE(fmt, args...) do { \
diff --git a/lib/librte_power/rte_power_kvm_vm.c 
b/lib/librte_power/rte_power_kvm_vm.c
index 52cac0c..2acfa60 100644
--- a/lib/librte_power/rte_power_kvm_vm.c
+++ b/lib/librte_power/rte_power_kvm_vm.c
@@ -38,7 +38,7 @@
 #include "guest_channel.h"
 #include "channel_commands.h"
 #include "rte_power_kvm_vm.h"
-#include "rte_power_common.h"
+#include "power_common.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
 
-- 
2.9.5



[dpdk-dev] [PATCH v3 3/4] power: clean up of acpi files

2017-12-12 Thread Marko Kovacevic
Rename private header file rte_power_acpi_cpufreq.c
to power_acpi_cpufreq.c.This prevents the private
functions from leaking into the documentation.
Change any private functions from rte_
to just .Reserve the rte_ for public functions.

Signed-off-by: Marko Kovacevic 

Acked-By: David Hunt 

---
 lib/librte_power/Makefile  |  2 +-
 ...e_power_acpi_cpufreq.c => power_acpi_cpufreq.c} | 32 +++---
 ...e_power_acpi_cpufreq.h => power_acpi_cpufreq.h} | 28 +--
 lib/librte_power/rte_power.c   | 28 +--
 4 files changed, 45 insertions(+), 45 deletions(-)
 rename lib/librte_power/{rte_power_acpi_cpufreq.c => power_acpi_cpufreq.c} 
(94%)
 rename lib/librte_power/{rte_power_acpi_cpufreq.h => power_acpi_cpufreq.h} 
(88%)

diff --git a/lib/librte_power/Makefile b/lib/librte_power/Makefile
index 1b1491d..bf5a55e 100644
--- a/lib/librte_power/Makefile
+++ b/lib/librte_power/Makefile
@@ -42,7 +42,7 @@ EXPORT_MAP := rte_power_version.map
 LIBABIVER := 1
 
 # all source are stored in SRCS-y
-SRCS-$(CONFIG_RTE_LIBRTE_POWER) := rte_power.c rte_power_acpi_cpufreq.c
+SRCS-$(CONFIG_RTE_LIBRTE_POWER) := rte_power.c power_acpi_cpufreq.c
 SRCS-$(CONFIG_RTE_LIBRTE_POWER) += rte_power_kvm_vm.c guest_channel.c
 
 # install this header file
diff --git a/lib/librte_power/rte_power_acpi_cpufreq.c 
b/lib/librte_power/power_acpi_cpufreq.c
similarity index 94%
rename from lib/librte_power/rte_power_acpi_cpufreq.c
rename to lib/librte_power/power_acpi_cpufreq.c
index 755dfff..fd1931f 100644
--- a/lib/librte_power/rte_power_acpi_cpufreq.c
+++ b/lib/librte_power/power_acpi_cpufreq.c
@@ -44,7 +44,7 @@
 #include 
 #include 
 
-#include "rte_power_acpi_cpufreq.h"
+#include "power_acpi_cpufreq.h"
 #include "power_common.h"
 
 #ifdef RTE_LIBRTE_POWER_DEBUG
@@ -311,7 +311,7 @@ power_init_for_setting_freq(struct rte_power_info *pi)
 }
 
 int
-rte_power_acpi_cpufreq_init(unsigned int lcore_id)
+power_acpi_cpufreq_init(unsigned int lcore_id)
 {
struct rte_power_info *pi;
 
@@ -352,7 +352,7 @@ rte_power_acpi_cpufreq_init(unsigned int lcore_id)
}
 
/* Set freq to max by default */
-   if (rte_power_acpi_cpufreq_freq_max(lcore_id) < 0) {
+   if (power_acpi_cpufreq_freq_max(lcore_id) < 0) {
RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
"to max\n", lcore_id);
goto fail;
@@ -419,7 +419,7 @@ power_set_governor_original(struct rte_power_info *pi)
 }
 
 int
-rte_power_acpi_cpufreq_exit(unsigned int lcore_id)
+power_acpi_cpufreq_exit(unsigned int lcore_id)
 {
struct rte_power_info *pi;
 
@@ -461,7 +461,7 @@ rte_power_acpi_cpufreq_exit(unsigned int lcore_id)
 }
 
 uint32_t
-rte_power_acpi_cpufreq_freqs(unsigned lcore_id, uint32_t *freqs, uint32_t num)
+power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num)
 {
struct rte_power_info *pi;
 
@@ -481,7 +481,7 @@ rte_power_acpi_cpufreq_freqs(unsigned lcore_id, uint32_t 
*freqs, uint32_t num)
 }
 
 uint32_t
-rte_power_acpi_cpufreq_get_freq(unsigned int lcore_id)
+power_acpi_cpufreq_get_freq(unsigned int lcore_id)
 {
if (lcore_id >= RTE_MAX_LCORE) {
RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
@@ -492,7 +492,7 @@ rte_power_acpi_cpufreq_get_freq(unsigned int lcore_id)
 }
 
 int
-rte_power_acpi_cpufreq_set_freq(unsigned lcore_id, uint32_t index)
+power_acpi_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
if (lcore_id >= RTE_MAX_LCORE) {
RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
@@ -503,7 +503,7 @@ rte_power_acpi_cpufreq_set_freq(unsigned lcore_id, uint32_t 
index)
 }
 
 int
-rte_power_acpi_cpufreq_freq_down(unsigned int lcore_id)
+power_acpi_cpufreq_freq_down(unsigned int lcore_id)
 {
struct rte_power_info *pi;
 
@@ -521,7 +521,7 @@ rte_power_acpi_cpufreq_freq_down(unsigned int lcore_id)
 }
 
 int
-rte_power_acpi_cpufreq_freq_up(unsigned int lcore_id)
+power_acpi_cpufreq_freq_up(unsigned int lcore_id)
 {
struct rte_power_info *pi;
 
@@ -539,7 +539,7 @@ rte_power_acpi_cpufreq_freq_up(unsigned int lcore_id)
 }
 
 int
-rte_power_acpi_cpufreq_freq_max(unsigned int lcore_id)
+power_acpi_cpufreq_freq_max(unsigned int lcore_id)
 {
if (lcore_id >= RTE_MAX_LCORE) {
RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
@@ -561,7 +561,7 @@ rte_power_acpi_cpufreq_freq_max(unsigned int lcore_id)
 }
 
 int
-rte_power_acpi_cpufreq_freq_min(unsigned int lcore_id)
+power_acpi_cpufreq_freq_min(unsigned int lcore_id)
 {
struct rte_power_info *pi;
 
@@ -578,7 +578,7 @@ rte_power_acpi_cpufreq_freq_min(unsigned int lcore_id)
 
 
 int
-rte_power_acpi_turbo_status(unsigned int lcore_id)
+power_acpi_turbo_status(unsigned int lcore_id)
 {
struct rte_power_info *pi;
 
@@ -594,7 +594,7 @@ rte_power_acpi_turbo_status(unsigned int lcore_id)
 
 
 int
-rte_power_acpi_enable_turbo(unsigned int lcore_id)
+power_acpi_enable_

[dpdk-dev] [PATCH v3 4/4] power: clean up of kvm files

2017-12-12 Thread Marko Kovacevic
rename private header file rte_power_kvm_vm.c
to power_kvm_vm.c. This prevents the private
functions from leaking into the documentation.
Change any private functions from
rte_ to just .
Reserve the rte_ for public functions

Signed-off-by: Marko Kovacevic 

Acked-By: David Hunt 

---
 lib/librte_power/Makefile  |  2 +-
 .../{rte_power_kvm_vm.c => power_kvm_vm.c} | 26 ++--
 .../{rte_power_kvm_vm.h => power_kvm_vm.h} | 28 +++---
 lib/librte_power/rte_power.c   | 28 +++---
 4 files changed, 42 insertions(+), 42 deletions(-)
 rename lib/librte_power/{rte_power_kvm_vm.c => power_kvm_vm.c} (84%)
 rename lib/librte_power/{rte_power_kvm_vm.h => power_kvm_vm.h} (85%)

diff --git a/lib/librte_power/Makefile b/lib/librte_power/Makefile
index bf5a55e..a35c50a 100644
--- a/lib/librte_power/Makefile
+++ b/lib/librte_power/Makefile
@@ -43,7 +43,7 @@ LIBABIVER := 1
 
 # all source are stored in SRCS-y
 SRCS-$(CONFIG_RTE_LIBRTE_POWER) := rte_power.c power_acpi_cpufreq.c
-SRCS-$(CONFIG_RTE_LIBRTE_POWER) += rte_power_kvm_vm.c guest_channel.c
+SRCS-$(CONFIG_RTE_LIBRTE_POWER) += power_kvm_vm.c guest_channel.c
 
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_POWER)-include := rte_power.h
diff --git a/lib/librte_power/rte_power_kvm_vm.c 
b/lib/librte_power/power_kvm_vm.c
similarity index 84%
rename from lib/librte_power/rte_power_kvm_vm.c
rename to lib/librte_power/power_kvm_vm.c
index 2acfa60..4b796f9 100644
--- a/lib/librte_power/rte_power_kvm_vm.c
+++ b/lib/librte_power/power_kvm_vm.c
@@ -37,7 +37,7 @@
 
 #include "guest_channel.h"
 #include "channel_commands.h"
-#include "rte_power_kvm_vm.h"
+#include "power_kvm_vm.h"
 #include "power_common.h"
 
 #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent"
@@ -46,7 +46,7 @@ static struct channel_packet 
pkt[CHANNEL_CMDS_MAX_VM_CHANNELS];
 
 
 int
-rte_power_kvm_vm_init(unsigned int lcore_id)
+power_kvm_vm_init(unsigned int lcore_id)
 {
if (lcore_id >= CHANNEL_CMDS_MAX_VM_CHANNELS) {
RTE_LOG(ERR, POWER, "Core(%u) is out of range 0...%d\n",
@@ -59,14 +59,14 @@ rte_power_kvm_vm_init(unsigned int lcore_id)
 }
 
 int
-rte_power_kvm_vm_exit(unsigned int lcore_id)
+power_kvm_vm_exit(unsigned int lcore_id)
 {
guest_channel_host_disconnect(lcore_id);
return 0;
 }
 
 uint32_t
-rte_power_kvm_vm_freqs(__attribute__((unused)) unsigned int lcore_id,
+power_kvm_vm_freqs(__attribute__((unused)) unsigned int lcore_id,
__attribute__((unused)) uint32_t *freqs,
__attribute__((unused)) uint32_t num)
 {
@@ -76,7 +76,7 @@ rte_power_kvm_vm_freqs(__attribute__((unused)) unsigned int 
lcore_id,
 }
 
 uint32_t
-rte_power_kvm_vm_get_freq(__attribute__((unused)) unsigned int lcore_id)
+power_kvm_vm_get_freq(__attribute__((unused)) unsigned int lcore_id)
 {
RTE_LOG(ERR, POWER, "rte_power_get_freq is not implemented "
"for Virtual Machine Power Management\n");
@@ -84,7 +84,7 @@ rte_power_kvm_vm_get_freq(__attribute__((unused)) unsigned 
int lcore_id)
 }
 
 int
-rte_power_kvm_vm_set_freq(__attribute__((unused)) unsigned int lcore_id,
+power_kvm_vm_set_freq(__attribute__((unused)) unsigned int lcore_id,
__attribute__((unused)) uint32_t index)
 {
RTE_LOG(ERR, POWER, "rte_power_set_freq is not implemented "
@@ -112,44 +112,44 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction)
 }
 
 int
-rte_power_kvm_vm_freq_up(unsigned int lcore_id)
+power_kvm_vm_freq_up(unsigned int lcore_id)
 {
return send_msg(lcore_id, CPU_POWER_SCALE_UP);
 }
 
 int
-rte_power_kvm_vm_freq_down(unsigned int lcore_id)
+power_kvm_vm_freq_down(unsigned int lcore_id)
 {
return send_msg(lcore_id, CPU_POWER_SCALE_DOWN);
 }
 
 int
-rte_power_kvm_vm_freq_max(unsigned int lcore_id)
+power_kvm_vm_freq_max(unsigned int lcore_id)
 {
return send_msg(lcore_id, CPU_POWER_SCALE_MAX);
 }
 
 int
-rte_power_kvm_vm_freq_min(unsigned int lcore_id)
+power_kvm_vm_freq_min(unsigned int lcore_id)
 {
return send_msg(lcore_id, CPU_POWER_SCALE_MIN);
 }
 
 int
-rte_power_kvm_vm_turbo_status(__attribute__((unused)) unsigned int lcore_id)
+power_kvm_vm_turbo_status(__attribute__((unused)) unsigned int lcore_id)
 {
RTE_LOG(ERR, POWER, "rte_power_turbo_status is not implemented for 
Virtual Machine Power Management\n");
return -ENOTSUP;
 }
 
 int
-rte_power_kvm_vm_enable_turbo(unsigned int lcore_id)
+power_kvm_vm_enable_turbo(unsigned int lcore_id)
 {
return send_msg(lcore_id, CPU_POWER_ENABLE_TURBO);
 }
 
 int
-rte_power_kvm_vm_disable_turbo(unsigned int lcore_id)
+power_kvm_vm_disable_turbo(unsigned int lcore_id)
 {
return send_msg(lcore_id, CPU_POWER_DISABLE_TURBO);
 }
diff --git a/lib/librte_power/rte_power_kvm_vm.h 
b/lib/librte_power/power_kvm_vm.h
similarity index 85%
rename from lib/librte_power/rte_power_kvm_vm.h
rename to lib/librte_power/po

Re: [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: add target queues in flow actions

2017-12-12 Thread Anoob Joseph

Hi Nelio,


On 12/12/2017 07:14 PM, Nelio Laranjeiro wrote:

Hi Anoob,

On Tue, Dec 12, 2017 at 06:13:08PM +0530, Anoob Joseph wrote:

Hi Nelio,


On 12/11/2017 07:34 PM, Nelio Laranjeiro wrote:

Mellanox INNOVA NIC needs to have final target queue actions to perform
inline crypto.

Signed-off-by: Nelio Laranjeiro 

---

Changes in v3:

   * removed PASSTHRU test for ingress.
   * removed check on configured queues for the queue action.

Changes in v2:

   * Test the rule by PASSTHRU/RSS/QUEUE and apply the first one validated.
---
   examples/ipsec-secgw/ipsec.c | 57 
++--
   examples/ipsec-secgw/ipsec.h |  2 +-
   2 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 17bd7620d..1b8b251c8 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -142,6 +142,7 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa 
*sa)
rte_eth_dev_get_sec_ctx(
sa->portid);
const struct rte_security_capability *sec_cap;
+   int ret = 0;
sa->sec_session = rte_security_session_create(ctx,
&sess_conf, ipsec_ctx->session_pool);
@@ -201,15 +202,67 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct 
ipsec_sa *sa)
sa->action[0].type = RTE_FLOW_ACTION_TYPE_SECURITY;
sa->action[0].conf = sa->sec_session;
-   sa->action[1].type = RTE_FLOW_ACTION_TYPE_END;
-
sa->attr.egress = (sa->direction ==
RTE_SECURITY_IPSEC_SA_DIR_EGRESS);
sa->attr.ingress = (sa->direction ==
RTE_SECURITY_IPSEC_SA_DIR_INGRESS);
+   if (sa->attr.ingress) {
+   uint8_t rss_key[40];
+   struct rte_eth_rss_conf rss_conf = {
+   .rss_key = rss_key,
+   .rss_key_len = 40,
+   };
+   struct rte_eth_dev *eth_dev;
+   union {
+   struct rte_flow_action_rss rss;
+   struct {
+   const struct rte_eth_rss_conf *rss_conf;
+   uint16_t num;
+   uint16_t queue[RTE_MAX_QUEUES_PER_PORT];
+   } local;
+   } action_rss;
+   unsigned int i;
+   unsigned int j;
+
+   sa->action[2].type = RTE_FLOW_ACTION_TYPE_END;
+   /* Try RSS. */
+   sa->action[1].type = RTE_FLOW_ACTION_TYPE_RSS;
+   sa->action[1].conf = &action_rss;
+   eth_dev = ctx->device;
+   rte_eth_dev_rss_hash_conf_get(sa->portid,
+ &rss_conf);
+   for (i = 0, j = 0;
+i < eth_dev->data->nb_rx_queues; ++i)
+   if (eth_dev->data->rx_queues[i])
+   action_rss.local.queue[j++] = i;
+   action_rss.local.num = j;
+   action_rss.local.rss_conf = &rss_conf;
+   ret = rte_flow_validate(sa->portid, &sa->attr,
+   sa->pattern, sa->action,
+   &err);
+   if (!ret)
+   goto flow_create;
+   /* Try Queue. */
+   sa->action[1].type = RTE_FLOW_ACTION_TYPE_QUEUE;
+   sa->action[1].conf =
+   &(struct rte_flow_action_queue){
+   .index = 0,
+   };
+   ret = rte_flow_validate(sa->portid, &sa->attr,
+   sa->pattern, sa->action,
+   &err);
+   if (ret)
+   goto flow_create_failure;
+   } else {
+   sa->action[1].type =
+   RTE_FLOW_ACTION_TYPE_PASSTHRU;
+   sa->action[2].t

Re: [dpdk-dev] [PATCHv3 0/4] dpdk: enhance EXPERIMENTAL api tagging

2017-12-12 Thread Bruce Richardson
On Mon, Dec 11, 2017 at 02:36:15PM -0500, Neil Horman wrote:
> Hey all-
>   A few days ago, I was lamenting the fact that, when reviewing patches I
> would frequently complain about ABI changes that were actually considered safe
> because they were part of the EXPERIMENTAL api set.  John M. asked me then 
> what
> I might do to improve the situation, and the following patch set is a proposal
> that I've come up with.
> 
>   In thinking about the problem I identified two issues that I think we
> can improve on in this area:
> 
> 1) Make experimental api calls more visible in the source code.  That is to 
> say,
> when reviewing patches, it would be nice to have some sort of visual reference
> that indicates that the changes being made are part of an experimental API and
> therefore ABI concerns need not be addressed
> 
> 2) Make experimenal api usage more visible to consumers of the DPDK, so that
> they can make a more informed decision about the API's they consume in their
> application.  We make an effort to document all the experimental API's, but
> there is no guarantee that a user will check the documentation before making 
> use
> of a new library.
> 
> This patch set attempts to achieve both of the above goals.  To do this I've
> added an __experimental macro tag, suitable for inserting into api forward
> declarations and definitions.
> 
> The presence of the tag in the header and c files where the api code resides
> increases the likelyhood that any patch submitted against them will include 
> the
> tag in the context, making it clear to reviewers that ABI stability isn't a
> concern here.
> 
> 
> Also, This tag marks each function it is used on with an attibute causing any
> use of the fuction to emit a warning during the build
> with a message indicating that the API call in question is not yet part of the
> stable interface.  Developers can then make an informed decision to suppress
> that warning or not.
> 
> Because there is internal use of several experimental API's, this set also
> includes a new override macro ALLOW_EXPERIMENTAL_APIS to automatically
> suprress these warnings.  I think its fair to assume that, for internal use, 
> we
> almost always want to suppress these warnings, as by definition any change to
> the apis (even their removal) must be done in parallel with an appropriate
> change in the calling locations, lest the dpdk build itself break.
> 
> Neil
> 
> ---
> Change Notes:
> v2)
> * Cleaned up checkpatch errors
> * Added Allowance for building experimental on BSD
> * Swapped Patch 3 and 4 so that we didn't have a commit level that issued
>   warnings/errors without need
> 
> v3)
> * On suggestion from Bruce, modify ALLOW_EXPERIMENTAL_APIS to be defined in
>   CFLAGS rather than a makefile variable.  This is more flexible in that it
>   allows us to suppress this specific feature rather than all uses of the 
>   deprecated attribute, as we might use it for other features in the furute
> 

Despite the fact that this is making yet more work for porting to a new
build system, I think this is a good idea to have. As such,

Acked-by: Bruce Richardson 



Re: [dpdk-dev] [PATCH v2] doc: update oldest supported kernel in Linux guide

2017-12-12 Thread Kovacevic, Marko


> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Tuesday, November 28, 2017 10:02 PM
> To: dev@dpdk.org
> Cc: step...@networkplumber.org; bl...@debian.org
> Subject: [dpdk-dev] [PATCH v2] doc: update oldest supported kernel in Linux
> guide
> 
> From: Stephen Hemminger 

Acked-by: Marko Kovacevic 


Re: [dpdk-dev] [PATCH] test/mempool: improve default mempool ops selection

2017-12-12 Thread Olivier MATZ
Hi Jerin,

On Fri, Nov 17, 2017 at 11:37:03PM +0530, Jerin Jacob wrote:
> Use of rte_eal_mbuf_default_mempool_ops() API will
> allow to override pool handler through "--mbuf-pool-ops-name"
> eal command line argument.
> 
> Signed-off-by: Jerin Jacob 
> ---
>  test/test/test_mempool.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/test/test/test_mempool.c b/test/test/test_mempool.c
> index 37ead503b..46eb5ce06 100644
> --- a/test/test/test_mempool.c
> +++ b/test/test/test_mempool.c
> @@ -565,7 +565,7 @@ test_mempool(void)
>  
>   /* Create a mempool based on Default handler */
>   printf("Testing %s mempool handler\n",
> -RTE_MBUF_DEFAULT_MEMPOOL_OPS);
> +rte_eal_mbuf_default_mempool_ops());
>   default_pool = rte_mempool_create_empty("default_pool",
>   MEMPOOL_SIZE,
>   MEMPOOL_ELT_SIZE,
> @@ -577,7 +577,7 @@ test_mempool(void)
>   goto err;
>   }
>   if (rte_mempool_set_ops_byname(default_pool,
> - RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL) < 0) {
> + rte_eal_mbuf_default_mempool_ops(), NULL) < 0) {
>   printf("cannot set %s handler\n",
>   RTE_MBUF_DEFAULT_MEMPOOL_OPS);

The error printf should also be modified (there is another one below).
Since all uses are in the same function, it's worth putting it in a local
variable.

Regards,
Olivier


Re: [dpdk-dev] [PATCH] test/mempool_perf: improve default mempool ops selection

2017-12-12 Thread Olivier MATZ
On Sun, Nov 19, 2017 at 10:25:31AM +0530, Jerin Jacob wrote:
> Use of rte_eal_mbuf_default_mempool_ops() API will
> allow to override pool handler through "--mbuf-pool-ops-name"
> eal command line argument.
> 
> Signed-off-by: Jerin Jacob 
> ---
>  test/test/test_mempool_perf.c | 15 +++
>  1 file changed, 7 insertions(+), 8 deletions(-)

My checkpatch sees this minor issue:

WARNING:TYPO_SPELLING: 'allow to' may be misspelled -
  perhaps 'allow (without "to", see
  
http://english.stackexchange.com/questions/60271/grammatical-complements-for-allow/60285#60285)'?


I don't this it's critical, and the official checkpatch did not see it, so
Acked-by: Olivier Matz 


Thanks


Re: [dpdk-dev] [PATCHv3 0/4] dpdk: enhance EXPERIMENTAL api tagging

2017-12-12 Thread Mcnamara, John


> -Original Message-
> From: Neil Horman [mailto:nhor...@tuxdriver.com]
> Sent: Monday, December 11, 2017 7:36 PM
> To: dev@dpdk.org
> Cc: tho...@monjalon.net; Mcnamara, John ;
> Richardson, Bruce 
> Subject: [PATCHv3 0/4] dpdk: enhance EXPERIMENTAL api tagging
> 
> Hey all-
>   A few days ago, I was lamenting the fact that, when reviewing
> patches I would frequently complain about ABI changes that were actually
> considered safe because they were part of the EXPERIMENTAL api set.  John
> M. asked me then what I might do to improve the situation, and the
> following patch set is a proposal that I've come up with.

Hi Neil,

Thanks for this and apologies in advance for making more work for you but
it would be good to have a short section in the Contributors Guide on how
to add/check experimental APIs. I think the information in this cover
letter could be repurposed along with a few code and shell examples.

Probably as a new high level section in the Contributors Guides:

http://dpdk.org/doc/guides/contributing/index.html

Thanks,

John


Re: [dpdk-dev] [PATCH v3 2/2] examples/ipsec-secgw: add target queues in flow actions

2017-12-12 Thread Nelio Laranjeiro
Hi Anoob,

On Tue, Dec 12, 2017 at 07:34:31PM +0530, Anoob Joseph wrote:
> Hi Nelio,
> 
> 
> On 12/12/2017 07:14 PM, Nelio Laranjeiro wrote:
> > Hi Anoob,
> > 
> > On Tue, Dec 12, 2017 at 06:13:08PM +0530, Anoob Joseph wrote:
> > > Hi Nelio,
> > > 
> > > 
> > > On 12/11/2017 07:34 PM, Nelio Laranjeiro wrote:
> > > > Mellanox INNOVA NIC needs to have final target queue actions to perform
> > > > inline crypto.
> > > > 
> > > > Signed-off-by: Nelio Laranjeiro 
> > > > 
> > > > ---
> > > > 
> > > > Changes in v3:
> > > > 
> > > >* removed PASSTHRU test for ingress.
> > > >* removed check on configured queues for the queue action.
> > > > 
> > > > Changes in v2:
> > > > 
> > > >* Test the rule by PASSTHRU/RSS/QUEUE and apply the first one 
> > > > validated.
> > > > ---
> > > >examples/ipsec-secgw/ipsec.c | 57 
> > > > ++--
> > > >examples/ipsec-secgw/ipsec.h |  2 +-
> > > >2 files changed, 56 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
> > > > index 17bd7620d..1b8b251c8 100644
> > > > --- a/examples/ipsec-secgw/ipsec.c
> > > > +++ b/examples/ipsec-secgw/ipsec.c
> > > > @@ -142,6 +142,7 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct 
> > > > ipsec_sa *sa)
> > > > 
> > > > rte_eth_dev_get_sec_ctx(
> > > > sa->portid);
> > > > const struct rte_security_capability *sec_cap;
> > > > +   int ret = 0;
> > > > sa->sec_session = 
> > > > rte_security_session_create(ctx,
> > > > &sess_conf, 
> > > > ipsec_ctx->session_pool);
> > > > @@ -201,15 +202,67 @@ create_session(struct ipsec_ctx *ipsec_ctx, 
> > > > struct ipsec_sa *sa)
> > > > sa->action[0].type = 
> > > > RTE_FLOW_ACTION_TYPE_SECURITY;
> > > > sa->action[0].conf = sa->sec_session;
> > > > -   sa->action[1].type = RTE_FLOW_ACTION_TYPE_END;
> > > > -
> > > > sa->attr.egress = (sa->direction ==
> > > > 
> > > > RTE_SECURITY_IPSEC_SA_DIR_EGRESS);
> > > > sa->attr.ingress = (sa->direction ==
> > > > 
> > > > RTE_SECURITY_IPSEC_SA_DIR_INGRESS);
> > > > +   if (sa->attr.ingress) {
> > > > +   uint8_t rss_key[40];
> > > > +   struct rte_eth_rss_conf rss_conf = {
> > > > +   .rss_key = rss_key,
> > > > +   .rss_key_len = 40,
> > > > +   };
> > > > +   struct rte_eth_dev *eth_dev;
> > > > +   union {
> > > > +   struct rte_flow_action_rss rss;
> > > > +   struct {
> > > > +   const struct rte_eth_rss_conf 
> > > > *rss_conf;
> > > > +   uint16_t num;
> > > > +   uint16_t 
> > > > queue[RTE_MAX_QUEUES_PER_PORT];
> > > > +   } local;
> > > > +   } action_rss;
> > > > +   unsigned int i;
> > > > +   unsigned int j;
> > > > +
> > > > +   sa->action[2].type = 
> > > > RTE_FLOW_ACTION_TYPE_END;
> > > > +   /* Try RSS. */
> > > > +   sa->action[1].type = 
> > > > RTE_FLOW_ACTION_TYPE_RSS;
> > > > +   sa->action[1].conf = &action_rss;
> > > > +   eth_dev = ctx->device;
> > > > +   
> > > > rte_eth_dev_rss_hash_conf_get(sa->portid,
> > > > + 
> > > > &rss_conf);
> > > > +   for (i = 0, j = 0;
> > > > +i < eth_dev->data->nb_rx_queues; 
> > > > ++i)
> > > > +   if (eth_dev->data->rx_queues[i])
> > > > +   
> > > > action_rss.local.queue[j++] = i;
> > > > +   action_rss.local.num = j;
> > > > +   action_rss.local.rss_conf = &rss_conf;
> > > > +   ret = rte_flow_validate(sa->portid, 
> > > > &sa->attr,
> > > > +   sa->pattern, 
> > > > sa->action,
> > > > +   &err);
> > > > +   if (!ret)
> > > > +

Re: [dpdk-dev] [PATCH] doc: fix issues in metrics example

2017-12-12 Thread Kovacevic, Marko


> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Mattias Rönnblom
> Sent: Wednesday, November 29, 2017 9:29 AM
> To: Mcnamara, John 
> Cc: dev@dpdk.org; Mattias Rönnblom 
> Subject: [dpdk-dev] [PATCH] doc: fix issues in metrics example
> 
> The metrics example didn't retrieve the metrics' names, and also had some more
> minor issues with repetitive error handling code and missing variable
> declarations.
> 
> Signed-off-by: Mattias Rönnblom 

Would it be more beneficial to keep the return in these two cases as not to do 
two jumps to go out instead of just one
And to remove the out: ; at the very end completely.

if (len == 0) {
-printf("No metrics to display (none have been registered)\n");
-return;
+printf("Cannot get metrics count.\n");
+goto out;
+} else if (len == 0) {
+printf("No metrics to display (none have been registered).\n");
+goto out;
 }


Re: [dpdk-dev] [RFC PATCH 3/3] doc: ethdev ABI change deprecation notice

2017-12-12 Thread Kovacevic, Marko


> -Original Message-
> From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Konstantin Ananyev
> Sent: Friday, December 1, 2017 2:48 PM
> To: dev@dpdk.org; dev@dpdk.org
> Cc: Ananyev, Konstantin 
> Subject: [dpdk-dev] [RFC PATCH 3/3] doc: ethdev ABI change deprecation notice
> 
> Signed-off-by: Konstantin Ananyev 
> ---
>  doc/guides/rel_notes/deprecation.rst | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/deprecation.rst
> b/doc/guides/rel_notes/deprecation.rst
> index 13e85432f..038b55fd5 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -8,6 +8,11 @@ API and ABI deprecation notices are to be posted here.
>  Deprecation Notices
>  ---
> 
> +* ethdev: an ABI changes for ``rte_ethdev`` are planned in v18.05.
> +  The size and layout of struct rte_eth_dev will change.
> +  Mainly to accommodate queue specific RX/TX function pointers, plus
> +  reorganize RX/TX callback related information.
> +
>  * eal: several API and ABI changes are planned for ``rte_devargs`` in v18.02.
>The format of device command line parameters will change. The bus will need
>to be explicitly stated in the device declaration. The enum ``rte_devtype``
> --
> 2.13.5

Acked-by: Marko Kovacevic 


Re: [dpdk-dev] [PATCH] test/mempool: improve default mempool ops selection

2017-12-12 Thread santosh

On Friday 17 November 2017 11:37 PM, Jerin Jacob wrote:
> Use of rte_eal_mbuf_default_mempool_ops() API will
> allow to override pool handler through "--mbuf-pool-ops-name"
> eal command line argument.
>
> Signed-off-by: Jerin Jacob 
> ---
>  test/test/test_mempool.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/test/test/test_mempool.c b/test/test/test_mempool.c
> index 37ead503b..46eb5ce06 100644
> --- a/test/test/test_mempool.c
> +++ b/test/test/test_mempool.c
> @@ -565,7 +565,7 @@ test_mempool(void)
>  
>   /* Create a mempool based on Default handler */
>   printf("Testing %s mempool handler\n",
> -RTE_MBUF_DEFAULT_MEMPOOL_OPS);
> +rte_eal_mbuf_default_mempool_ops());
>   default_pool = rte_mempool_create_empty("default_pool",
>   MEMPOOL_SIZE,
>   MEMPOOL_ELT_SIZE,
> @@ -577,7 +577,7 @@ test_mempool(void)
>   goto err;
>   }
>   if (rte_mempool_set_ops_byname(default_pool,
> - RTE_MBUF_DEFAULT_MEMPOOL_OPS, NULL) < 0) {
> + rte_eal_mbuf_default_mempool_ops(), NULL) < 0) {
>   printf("cannot set %s handler\n",
>   RTE_MBUF_DEFAULT_MEMPOOL_OPS);

Pl. replace error printf _ops with _mbuf_default_mempool_ops.
With that:
Acked-by: Santosh Shukla 

Thanks.



  1   2   >