Commit Graph

35 Commits

Author SHA1 Message Date
Moti Haimovsky
f5bf91de73 net/mlx5: support flow counters using devx
This commit adds counters support when creating flows via direct
verbs. The implementation uses devx interface in order to create
query and delete the counters.
This support requires MLNX_OFED_LINUX-4.5-0.1.0.1 installation.

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2019-01-14 17:44:29 +01:00
Dekel Peled
4bb14c83df net/mlx5: support modify header using Direct Verbs
This patch implements the set of actions to support offload
of packet header modifications to MLX5 NIC.

Implementation is based on RFC [1].

[1] http://mails.dpdk.org/archives/dev/2018-November/119971.html

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2019-01-03 12:56:43 +01:00
Dekel Peled
38f7efaaf5 net/mlx5: fix MPLS item validation
Update the mlx5_flow_validate_item_mpls() function to allow
MPLS over IP, UDP, and GRE.
Modify the flow_dv_validate() function with the new logic introduced
in previous patch of this series: set new variable last_item
after each validation, update item_flags after each item iteration.
The new variable last_item is sent to mlx5_flow_validate_item_mpls()
and used to validate the MPLS item.
Same change implemented in flow_verbs_validate().

Update the mlx5_flow_validate_item_mpls() function to verify that
device configuration has mpls_en set to 1.
This code was added earlier this year, but unintentionaly removed
in recent versions.

Fixes: 84c406e745 ("net/mlx5: add flow translate function")

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-16 10:45:37 +01:00
Dekel Peled
d1abe664dd net/mlx5: add MPLS to Direct Verbs flow engine
The support in MPLS on this flow engine was overlooked. It's absence is
critical because there are required actions for MPLS which can be done
only with the DV engine.

To set correctly the MPLS filter, we need to reason about the flow item
before the MPLS (UDP, GRE or other).
To do that, a new variable last_item was added and updated after each
translation. the full item flags are updated after each item iteration.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-16 10:45:37 +01:00
Viacheslav Ovsiienko
a3166356ab net/mlx5: fix flow query routine in Direct Verbs
The flow_dv_query() just returns -ENOTSUP value and does not
set provided error parameter structure, that crashes the
port_flow_query(). The patch fixes flow_db_query(), now it
sets an error parameter structure.

Fixes: 684dafe795 ("net/mlx5: add flow query abstraction interface")

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-16 10:45:38 +01:00
Yongseok Koh
e31b6a4151 net/mlx5: fix Direct Verbs RSS hash field
As mlx5_flow_hashfields_adjust() refers to flow->rss, actions must be
translated prior to items like in Verbs. Otherwise, hash fields are not
correctly set.

Fixes: d02cb06912 ("net/mlx5: add Direct Verbs translate actions")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-14 00:35:53 +01:00
Yongseok Koh
3193c2494e net/mlx5: fix L4 protocol validation
- Currently, no device supports partial mask for protocol in IP header.
- As there could be multiple IP items, next_protocol variable in flow
  validation has to be reset for inner layer. Otherwise, inner TCP/UDP
  will see protocol number of outer IP header.
- Remove redundant protocol checking for MPLS, which is done in
  mlx5_flow_validate_item_mpls().

Fixes: 3d69434113 ("net/mlx5: add Direct Verbs validation function")
Fixes: 23c1d42c71 ("net/mlx5: split flow validation to dedicated function")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-14 00:35:53 +01:00
Yongseok Koh
636a71dedc net/mlx5: fix device flow reference
dev_flow->verbs is mistakenly used instead of dev_flow->dv. A sanity
check is added for debugging purpose.

Fixes: fc2c498ccb ("net/mlx5: add Direct Verbs translate items")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-14 00:35:52 +01:00
Yongseok Koh
c1cfb132fa net/mlx5: remove flags setting from flow preparation
Even though flow_drv_prepare() takes item_flags and action_flags to be
filled in, those are not used and will be overwritten by parsing of
flow_drv_translate(). There's no reason to keep the flags and fill it.
Appropriate notes are added to the documentation of flow_drv_prepare() and
flow_drv_translate().

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
2018-11-05 15:01:25 +01:00
Yongseok Koh
9ce75f5122 net/mlx5: fix Direct Verbs flow tunnel
1) Fix layer parsing
In translation of tunneled flows, dev_flow->layers must not be used to
check tunneled layer as it contains all the layers parsed from
flow_drv_prepare(). Checking tunneled layer is needed to distinguish
between outer and inner item. This should be based on dynamic parsing. With
dev_flow->layers on a tunneled flow, items will always be interpreted as
inner as dev_flow->layer already has all the items. Dynamic parsing
(item_flags) is added as there's no such code.

2) Refactoring code
- flow_dv_create_item() and flow_dv_create_action() are merged into
  flow_dv_translate() for consistency with Verbs and *_validate().

Fixes: 2466364115 ("net/mlx5: fix flow tunnel handling")
Fixes: d02cb06912 ("net/mlx5: add Direct Verbs translate actions")
Fixes: fc2c498ccb ("net/mlx5: add Direct Verbs translate items")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
2018-11-05 15:01:25 +01:00
Ophir Munk
f1b85a2719 net/mlx5: support default RSS key as null
Applications which add RSS rules must supply an RSS key and length.
If an application is only interested in default RSS operation it
should not care about the exact RSS key.
By setting the key to NULL - the PMD will use the default RSS key.
In addition if the application does not care about the RSS type it can
set it to 0 and the PMD will use the default type (ETH_RSS_IP).

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-05 15:01:25 +01:00
Dekel Peled
c513f05cde net/mlx5: add caching of encap/decap actions
Make flow encap and decap Verbs actions cacheable resources.
Store created actions in local database.
This enables MLX5 PMD reuse of existing actions.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-05 15:01:25 +01:00
Dekel Peled
8ba9eee4ce net/mlx5: add raw data encap/decap to Direct Verbs
This patch implements the encap and decap actions, using raw data,
in DV flow for MLX5 PMD.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-05 15:01:25 +01:00
Dekel Peled
4b8727f08b net/mlx5: add NVGRE decap action to Direct Verbs
This patch implements the NVGRE decap action in DV flow for MLX5 PMD.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-05 15:01:25 +01:00
Dekel Peled
a124cff00f net/mlx5: add NVGRE encap action to Direct Verbs
This patch implements the nvgre encap action in DV flow for MLX5 PMD.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-05 15:01:25 +01:00
Dekel Peled
49d6465af3 net/mlx5: add VXLAN decap action to Direct Verbs
This patch implements the VXLAN decap action in DV flow for MLX5 PMD.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-05 15:01:25 +01:00
Dekel Peled
34d41b7aa3 net/mlx5: add VXLAN encap action to Direct Verbs
This patch implements the VXLAN encap action in DV flow for MLX5 PMD.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-11-05 15:01:25 +01:00
Dekel Peled
7199088f9d net/mlx5: fix memory leak on Direct Verbs error
Add freeing of allocated memory before exiting on mlx5dv error.

Fixes: fc2c498ccb ("net/mlx5: add Direct Verbs translate items")

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
2018-11-05 15:01:25 +01:00
Yongseok Koh
0ddd11437a net/mlx5: fix bit width of item and action flags
Most of the code uses uint64_t for MLX5_FLOW_LAYER_* and
MLX5_FLOW_ACTION_*, but there're some code using uint32_t.

Fixes: 2ed2fe5f0a ("net/mlx5: rewrite IP address UDP/TCP port by E-Switch")
Fixes: 57123c00c1 ("net/mlx5: add Linux TC flower driver for E-Switch flow")
Fixes: fc2c498ccb ("net/mlx5: add Direct Verbs translate items")
Fixes: 3d69434113 ("net/mlx5: add Direct Verbs validation function")
Fixes: 84c406e745 ("net/mlx5: add flow translate function")
Fixes: 23c1d42c71 ("net/mlx5: split flow validation to dedicated function")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-10-26 22:14:06 +02:00
Yongseok Koh
2466364115 net/mlx5: fix flow tunnel handling
Both rte_flow and mlx5_flow redundantly have item flags. And it is not
properly set in the code. This causes wrong tunnel flag handling. A
rte_flow can have multiple expanded device flows if the flow has an RSS
action. Therefore, mlx5_flow should have the layers field.

Fixes: c4d9b9f7f3 ("net/mlx5: add Direct Verbs final functions")
Fixes: fc2c498ccb ("net/mlx5: add Direct Verbs translate items")
Fixes: 3d69434113 ("net/mlx5: add Direct Verbs validation function")
Fixes: 84c406e745 ("net/mlx5: add flow translate function")
Fixes: 4e05a229c5 ("net/mlx5: add flow prepare function")
Fixes: 23c1d42c71 ("net/mlx5: split flow validation to dedicated function")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-10-26 22:14:06 +02:00
Yongseok Koh
2096f61b95 net/mlx5: fix flow mark ID conversion in Direct Verbs
Fixes: d02cb06912 ("net/mlx5: add Direct Verbs translate actions")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
2018-10-26 22:14:06 +02:00
Yongseok Koh
39bee16117 net/mlx5: fix wildcard item for Direct Verbs
If a network layer is specified with no spec, it means wildcard match.
flow_dv_translate_item_*() returns without writing anything if spec is
null and it causes creation of wrong flow. E.g., the following flow has to
patch with any ipv4 packet.

  flow create 0 ingress pattern eth / ipv4 / end actions ...

But, with the current code, it matches any packet because PMD doesn't write
anything about IPv4. The matcher value and mask becomes completely zero. It
should have written the IP version at least. It is same for the rest of
items.

Even if the spec is null, PMD has to write constant fields before return,
e.g. IP version and IP protocol number.

Fixes: fc2c498ccb ("net/mlx5: add Direct Verbs translate items")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
2018-10-26 22:14:06 +02:00
Yongseok Koh
6949c43c14 net/mlx5: fix item validation in Direct Verbs
1) remove MPLS item in validation as it doesn't have a translator.

2) add missing NVGRE item to validation

3) match switch-case order between validation and translation.

Fixes: fc2c498ccb ("net/mlx5: add Direct Verbs translate items")
Fixes: 3d69434113 ("net/mlx5: add Direct Verbs validation function")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
2018-10-26 22:14:06 +02:00
Yongseok Koh
31b1999991 net/mlx5: fix UDP hash field flag in Direct Verbs
Fixes: fc2c498ccb ("net/mlx5: add Direct Verbs translate items")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
2018-10-26 22:14:06 +02:00
Dekel Peled
6bd7fbd03c net/mlx5: support metadata as flow rule criteria
As described in series starting at [1], it adds option to set
metadata value as match pattern when creating a new flow rule.

This patch adds metadata support in mlx5 driver, in two parts:
- Add the validation and setting of metadata value in matcher,
  when creating a new flow rule.
- Add the passing of metadata value from mbuf to wqe when
  indicated by ol_flag, in different burst functions.

[1] "ethdev: support metadata as flow rule criteria"
    http://mails.dpdk.org/archives/dev/2018-September/113269.html

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
2018-10-26 22:14:06 +02:00
Moti Haimovsky
684dafe795 net/mlx5: add flow query abstraction interface
Flow engine now supports multiple driver paths with each having
its own flow query implantation routine.
This patch adds an abstraction to the flow query routine in accordance
to commit 0c76d1c9a1 ("net/mlx5: add abstraction for multiple flow
drivers") done by Yongseok Koh.

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
2018-10-26 22:14:05 +02:00
Shahaf Shuler
cd18e1b72f net/mlx5: fix build on Arm
On some ARM environment, the below compilation error will be seen

dpdk/drivers/net/mlx5/mlx5_flow_dv.c: In function
'flow_dv_translate_item_nvgre':
/tmp/dpdk/drivers/net/mlx5/mlx5_flow_dv.c:785:22: error: pointer targets
in initialization differ in signedness [-Werror=pointer-sign]
  const char *tni_v = nvgre_v->tni;

The reason for this error is that nvgre_v->tni is defined as byte array
in size of 3B. However the code in the function iterate till the 4B in
order to copy/set also the subsequent field after it (flow_id)

Fixing by pointing to this struct from a different pointer.

Fixes: fc2c498ccb ("net/mlx5: add Direct Verbs translate items")

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
2018-10-18 10:24:39 +02:00
Moti Haimovsky
92378c2b7f net/mlx5: support e-switch TCP-flags flow filter
This patch adds support for offloading flow rules with TCP-flags
filter to mlx5 eswitch Hardwrae.

With mlx5 it is possible to offload a limited set of flow rules to
the mlxsw (or e-switch) using the DPDK flow commands using the
"transfer" attribute. This set of flow rules also supports filtering
according to the values found in the TCP flags.
This patch implements this offload capability in the mlx5 PMD under
transfer attribute.

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
2018-10-11 18:56:02 +02:00
Dekel Peled
3e9fa07908 net/mlx5: allow flow rule with attribute egress
This patch complements [1], adding to MLX5 PMD the option to set
flow rule for egress traffic.

[1] "net/mlx5: support metadata as flow rule criteria"
    http://mails.dpdk.org/archives/dev/2018-September/113275.html

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
2018-10-11 18:56:02 +02:00
Yongseok Koh
0c76d1c9a1 net/mlx5: add abstraction for multiple flow drivers
Flow engine has to support multiple driver paths. Verbs/DV for NIC flow
steering and Linux TC flower for E-Switch flow steering. In the future,
another flow driver could be added (devX).

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
2018-10-11 18:53:49 +02:00
Ori Kam
c4d9b9f7f3 net/mlx5: add Direct Verbs final functions
This commits add the missing function which are apply, remove, and
destroy.

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
2018-10-11 18:53:49 +02:00
Ori Kam
d02cb06912 net/mlx5: add Direct Verbs translate actions
In this commit we add the translation of flow actions.
Unlike the Verbs API actions are separeted from the items and are passed
to the API in array structure.
Since the target action like RSS require the QP information those
actions are handled both in the translate action and in the apply.

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
2018-10-11 18:53:49 +02:00
Ori Kam
fc2c498ccb net/mlx5: add Direct Verbs translate items
This commit handles the translation of the requested flow into Direct
Verbs API.

The Direct Verbs introduce the matcher object which acts as shared mask
for all flows that are using the same mask. So in this commit we
translate the item and get in return a matcher and the value that should
be matched.

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
2018-10-11 18:53:49 +02:00
Ori Kam
865a0c1567 net/mlx5: add Direct Verbs prepare function
This function allocates the Direct Verbs device flow, and
introduce the relevant PRM structures.

This commit also adds the matcher object. The matcher object acts as a
mask and should be shared between flows. For example all rules that
should match source IP with full mask should use the same matcher. A
flow that should match dest IP or source IP but without full mask should
have a new matcher allocated.

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
2018-10-11 18:53:49 +02:00
Ori Kam
3d69434113 net/mlx5: add Direct Verbs validation function
This is commit introduce the Direct Verbs driver API.
The Direct Verbs is an API adds new features like encapsulation, match
on metatdata.
In this commit the validation function was added, most of the validation
is done with functions that are also in use for the Verbs API.

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
2018-10-11 18:53:49 +02:00