ethdev: add flow action to swap MAC addresses
This action is useful for offloading loopback mode, where the hardware will swap source and destination MAC addresses in the outermost Ethernet header before looping back the packet. This action can be used in conjunction with other rewrite actions to achieve MAC layer transparent NAT where the MAC addresses are swapped before either the source or destination MAC address is rewritten and NAT is performed. Must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error should be returned by the PMDs. Original work by Shagun Agrawal Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
This commit is contained in:
parent
48f523f625
commit
8287597059
@ -255,6 +255,7 @@ enum index {
|
||||
ACTION_SET_TP_SRC_TP_SRC,
|
||||
ACTION_SET_TP_DST,
|
||||
ACTION_SET_TP_DST_TP_DST,
|
||||
ACTION_MAC_SWAP,
|
||||
};
|
||||
|
||||
/** Maximum size for pattern in struct rte_flow_item_raw. */
|
||||
@ -834,6 +835,7 @@ static const enum index next_action[] = {
|
||||
ACTION_SET_IPV6_DST,
|
||||
ACTION_SET_TP_SRC,
|
||||
ACTION_SET_TP_DST,
|
||||
ACTION_MAC_SWAP,
|
||||
ZERO,
|
||||
};
|
||||
|
||||
@ -2626,6 +2628,14 @@ static const struct token token_list[] = {
|
||||
(struct rte_flow_action_set_tp, port)),
|
||||
.call = parse_vc_conf,
|
||||
},
|
||||
[ACTION_MAC_SWAP] = {
|
||||
.name = "mac_swap",
|
||||
.help = "Swap the source and destination MAC addresses"
|
||||
" in the outermost Ethernet header",
|
||||
.priv = PRIV_ACTION(MAC_SWAP, 0),
|
||||
.next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
|
||||
.call = parse_vc,
|
||||
},
|
||||
};
|
||||
|
||||
/** Remove and return last entry from argument stack. */
|
||||
|
@ -2184,6 +2184,25 @@ flow pattern item. Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
|
||||
| ``port`` | new TCP/UDP destination port |
|
||||
+---------------+-------------------------+
|
||||
|
||||
Action: ``MAC_SWAP``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Swap the source and destination MAC addresses in the outermost Ethernet
|
||||
header.
|
||||
|
||||
It must be used with a valid RTE_FLOW_ITEM_TYPE_ETH flow pattern item.
|
||||
Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned.
|
||||
|
||||
.. _table_rte_flow_action_mac_swap:
|
||||
|
||||
.. table:: MAC_SWAP
|
||||
|
||||
+---------------+
|
||||
| Field |
|
||||
+===============+
|
||||
| no properties |
|
||||
+---------------+
|
||||
|
||||
Negative types
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -69,6 +69,11 @@ New Features
|
||||
* Modify source and destination port numbers in the outermost TCP/UDP
|
||||
headers.
|
||||
|
||||
* **Added new Flow API action to swap MAC addresses in Ethernet header.**
|
||||
|
||||
Added new Flow API action to swap the source and destination MAC
|
||||
addresses in the outermost Ethernet header.
|
||||
|
||||
* **Add support to offload more flow match and actions for CXGBE PMD**
|
||||
|
||||
Flow API support has been enhanced for CXGBE Poll Mode Driver to offload:
|
||||
|
@ -3732,6 +3732,9 @@ This section lists supported actions and their attributes, if any.
|
||||
|
||||
- ``port``: New TCP/UDP destination port number.
|
||||
|
||||
- ``mac_swap``: Swap the source and destination MAC addresses in the outermost
|
||||
Ethernet header.
|
||||
|
||||
Destroying flow rules
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -135,6 +135,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
|
||||
sizeof(struct rte_flow_action_set_tp)),
|
||||
MK_FLOW_ACTION(SET_TP_DST,
|
||||
sizeof(struct rte_flow_action_set_tp)),
|
||||
MK_FLOW_ACTION(MAC_SWAP, 0),
|
||||
};
|
||||
|
||||
static int
|
||||
|
@ -1568,6 +1568,17 @@ enum rte_flow_action_type {
|
||||
* See struct rte_flow_action_set_tp.
|
||||
*/
|
||||
RTE_FLOW_ACTION_TYPE_SET_TP_DST,
|
||||
|
||||
/**
|
||||
* Swap the source and destination MAC addresses in the outermost
|
||||
* Ethernet header.
|
||||
*
|
||||
* If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
|
||||
* then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
|
||||
*
|
||||
* No associated configuration structure.
|
||||
*/
|
||||
RTE_FLOW_ACTION_TYPE_MAC_SWAP,
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user