introduce support for hairpin between two ports
Hairpin functionality only supports one single port mode (e.g testpmd application) in the current implementation. It means that the traffic will be sent out from the same port it comes. There is no such restriction for some NICs, and strong demand to support two ports hairpin mode in real-life cases.
Two ports hairpin mode does not really mean hairpin will only support two ports in a single application. Indeed, it also needs to support the single port hairpin today for compatibility. In the meanwhile, 'two ports' means the ingress and egress ports of the traffic could Be different. And also, there is no restriction that
1. traffic from the same ingress port must go to the same egress port
2. traffic from the port that as 'egress' for other traffic flows must go to their 'ingress' port
The configuration should be flexible and the behavior of traffic will be decided by the rte flows.
Usually, during the startup phase, all the hairpin configurations except flows should be done. It means that hairpin TXQ and peer RXQ should be bound together. It is feasible in single port mode and transparent to the application. In two ports mode, there may be some problems for the queues configuring and binding.
1. Once TXQ & RXQ belong to different ports, it would be hard to configure the first port when the initialization of the second port is not done. Also, it is not proper to configure the first port during the second one starting.
2. The port could be attached and detached dynamically. Hairpin between these ports should support dynamic configuration.
In two ports hairpin mode, since the TXQ and RXQ belong to different ports. If some actions need to be done in the TX part, the egress flow could be inserted explicitly and managed separately from the RX part. What's more, one egress flow could be shared for different ingress flows from the same or different ports.
In order to satisfy these, some changes on the current rte ethdev and flow APIs are needed and some new APIs will be introduced.
1. Data structures in 'rte_ethdev.h'
Two new members are added.
struct rte_eth_hairpin_conf {
uint16_t peer_count; /**< The number of peers. */
struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS];
uint16_t tx_explicit;
uint16_t manual_bind;
};'tx_explicit': If 0, PMD will help to insert the egress flow in a implicit way. If 1, the application will insert it by itself. 'manual_bind': If 0, PMD will try to bind hairpin TXQ and RXQ peer automatically, like in today's single port hairpin mode and this is for backward compatibility. If 1, then manual bind API will be called. The application should ensure there is no conflict for the hairpin peer configurations between TX & RX as today and PMD could check them inside. For new member 'tx_explicit', all queue pairs from one ingress port to the same egress are suggested to have the same value in order not to create chaos, like in RSS cases.
For new member 'manual_bind', the same suggestion is applicable. The support for the new members will be decided by the NICs' capacity and real-life usage from the application.
2. New macros in 'rte_ethdev.h'RTE_ETH_HAIRPIN_BIND_AUTO (0)RTE_ETH_HAIRPIN_BIND_MANUAL (1) RTE_ETH_HAIRPIN_TXRULE_IMPLICIT (0) RTE_ETH_HAIRPIN_TXRULE_EXPLICIT (1)
These are used for the new members in 'struct rte_eth_hairpin_conf'.
3. New function APIs in 'rte_ethdev.h'
* int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port)
* typedef int (*eth_hairpin_bind)(struct rte_eth_dev *dev,
uint16_t rx_port);
This function will be used to bind one port egress to the peer port ingress. If 'rx_port' is equal to RTE_MAX_ETHPORTS, then all the ports will be traversed to bind hairpin egress queues to all of their ingress queues configured. The application needs to call it repeatedly to bind all egress ports.
This should be called after the hairpin queues are set up and devices are started. If 'manual_bind' is not specified, no need to call this API. A function pointer with 'eth_hairpin_bind' type should be provided by the PMD to execute the hardware setting in the driver. 0 return value means success and a negative value will be returned to indicate the actual failure.
* int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port)
* typedef int (*eth_hairpin_unbind)(struct rte_eth_dev *dev,
uint16_t rx_port);
This function will unbind one port egress to the peer port ingress, only one direction hairpin will be unbound. Unbinding of the opposite direction needs another call of this API.
If 'rx_port' is equal to RTE_MAX_ETHPORTS, all the ports will be traversed to do the queues unbind (if any). The application needs to call it repeatedly to unbind all egress ports.
The API could be called without stopping or closing the eth device, but the application should ensure the flows inserted for the hairpin port pairs be handled properly. The traffic behavior should be divinable after unbound. It is suggested to remove all the flows for the same direction of a port pairs to be unbound, on both ports. A function pointer with 'eth_hairpin_unbind' type should be provided by the PMD to execute the hardware setting in the driver. 0 return value means success and a negative value will be returned to indicate the actual failure.
After unbinding, the bind API could be called again to enable it. No peer reconfiguring is supported now without closing the devices.
4. New rte_flow item
* RTE_FLOW_ITEM_TYPE_TX_QUEUE
struct rte_flow_item_tx_queue {
uint32_t queue;
};This provides a new item to match for an egress packet. In two ports hairpin mode, since the TX rules could be inserted explicitly on the egress port, it is hard to distinguish the hairpin packets from the software packets. Even if with metadata, it may require complex management. The support new rte_flow item is optional, depending on the NIC's capacity. With this item, a few wildcard rules could be inserted for hairpin to support some common actions.
When switching to two ports hairpin mode with explicit TX rules, the metadata could be used to provide the 'connection' for a packet between ingress & egress.
1. The packet header might be changed due to the NAT of DECAP in the ingress, and the inner header or other parts may be different.
2. Different ingress flow rules could share the same egress rule to simplify rules management.
The rte_flow examples are like below (port 0 RX X -> port 1 TX Y):
flow create 0 ingress group M pattern eth / ... / end actions queue index is X / set_meta data is V / end X is the ingress hairpin queue index.
flow create 1 egress group N pattern eth / meta data is V / end actions vxlan_encap / end
flow create 1 egress group 0 pattern eth / tx_queue index is Y / end actions jump group N / end Y is the egress hairpin queue index. This wildcard flow will help to
redirect all the ethernet packets from hairpin TX queue Y to some
specific group for further handling. In the meanwhile, other traffic
sent from software will not be impacted by this wildcard rule.
To verify this in testpmd, some changes are also required.
1. During startup phase, hairpin binding will use the chaining mode. E.g. if 3 ports are probed, hairpin traffic will be like this port A -> port B, Port B -> port C, port C -> port A In only a single port is probed
port A -> port A
2. flow command line will add support to parse tx queue index pattern format: tx_queue index is UNSIGNED / ...
Thanks
v2 cover introduce support for hairpin between two ports
Hairpin functionality only supports one single port mode (e.g testpmd application) in the current implementation. It means that the traffic will be sent out from the same port it comes. There is no such restriction for some NICs, and strong demand to support two ports hairpin mode in real-life cases.
Two ports hairpin mode does not really mean hairpin will only support two ports in a single application. Indeed, it also needs to support the single port hairpin today for compatibility. In the meanwhile, 'two ports' means the ingress and egress ports of the traffic could Be different. And also, there is no restriction that
1. traffic from the same ingress port must go to the same egress port
2. traffic from the port that as 'egress' for other traffic flows must go to their 'ingress' port
The configuration should be flexible and the behavior of traffic will be decided by the rte flows.
Usually, during the startup phase, all the hairpin configurations except flows should be done. It means that hairpin TXQ and peer RXQ should be bound together. It is feasible in single port mode and transparent to the application. In two ports mode, there may be some problems for the queues configuring and binding.
1. Once TXQ & RXQ belong to different ports, it would be hard to configure the first port when the initialization of the second port is not done. Also, it is not proper to configure the first port during the second one starting.
2. The port could be attached and detached dynamically. Hairpin between these ports should support dynamic configuration.
In two ports hairpin mode, since the TXQ and RXQ belong to different ports. If some actions need to be done in the TX part, the egress flow could be inserted explicitly and managed separately from the RX part. What's more, one egress flow could be shared for different ingress flows from the same or different ports.
In order to satisfy these, some changes on the current rte ethdev and flow APIs are needed and some new APIs will be introduced.
1. Data structures in 'rte_ethdev.h'
Two new members are added.
struct rte_eth_hairpin_conf {
uint16_t peer_count; /**< The number of peers. */
struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS];
uint16_t tx_explicit;
uint16_t manual_bind;
};'tx_explicit': If 0, PMD will help to insert the egress flow in a implicit way. If 1, the application will insert it by itself. 'manual_bind': If 0, PMD will try to bind hairpin TXQ and RXQ peer automatically, like in today's single port hairpin mode and this is for backward compatibility. If 1, then manual bind API will be called. The application should ensure there is no conflict for the hairpin peer configurations between TX & RX as today and PMD could check them inside. For new member 'tx_explicit', all queue pairs from one ingress port to the same egress are suggested to have the same value in order not to create chaos, like in RSS cases.
For new member 'manual_bind', the same suggestion is applicable. The support for the new members will be decided by the NICs' capacity and real-life usage from the application.
2. New macros in 'rte_ethdev.h'RTE_ETH_HAIRPIN_BIND_AUTO (0)RTE_ETH_HAIRPIN_BIND_MANUAL (1) RTE_ETH_HAIRPIN_TXRULE_IMPLICIT (0) RTE_ETH_HAIRPIN_TXRULE_EXPLICIT (1)
These are used for the new members in 'struct rte_eth_hairpin_conf'.
3. New function APIs in 'rte_ethdev.h'
* int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port)
* typedef int (*eth_hairpin_bind)(struct rte_eth_dev *dev,
uint16_t rx_port);
This function will be used to bind one port egress to the peer port ingress. If 'rx_port' is equal to RTE_MAX_ETHPORTS, then all the ports will be traversed to bind hairpin egress queues to all of their ingress queues configured. The application needs to call it repeatedly to bind all egress ports.
This should be called after the hairpin queues are set up and devices are started. If 'manual_bind' is not specified, no need to call this API. A function pointer with 'eth_hairpin_bind' type should be provided by the PMD to execute the hardware setting in the driver. 0 return value means success and a negative value will be returned to indicate the actual failure.
* int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port)
* typedef int (*eth_hairpin_unbind)(struct rte_eth_dev *dev,
uint16_t rx_port);
This function will unbind one port egress to the peer port ingress, only one direction hairpin will be unbound. Unbinding of the opposite direction needs another call of this API.
If 'rx_port' is equal to RTE_MAX_ETHPORTS, all the ports will be traversed to do the queues unbind (if any). The application needs to call it repeatedly to unbind all egress ports.
The API could be called without stopping or closing the eth device, but the application should ensure the flows inserted for the hairpin port pairs be handled properly. The traffic behavior should be divinable after unbound. It is suggested to remove all the flows for the same direction of a port pairs to be unbound, on both ports. A function pointer with 'eth_hairpin_unbind' type should be provided by the PMD to execute the hardware setting in the driver. 0 return value means success and a negative value will be returned to indicate the actual failure.
After unbinding, the bind API could be called again to enable it. No peer reconfiguring is supported now without closing the devices.
4. New rte_flow item
* RTE_FLOW_ITEM_TYPE_TX_QUEUE
struct rte_flow_item_tx_queue {
uint32_t queue;
};This provides a new item to match for an egress packet. In two ports hairpin mode, since the TX rules could be inserted explicitly on the egress port, it is hard to distinguish the hairpin packets from the software packets. Even if with metadata, it may require complex management. The support new rte_flow item is optional, depending on the NIC's capacity. With this item, a few wildcard rules could be inserted for hairpin to support some common actions.
When switching to two ports hairpin mode with explicit TX rules, the metadata could be used to provide the 'connection' for a packet between ingress & egress.
1. The packet header might be changed due to the NAT of DECAP in the ingress, and the inner header or other parts may be different.
2. Different ingress flow rules could share the same egress rule to simplify rules management.
The rte_flow examples are like below (port 0 RX X -> port 1 TX Y):
flow create 0 ingress group M pattern eth / … / end actions queue index is X / set_meta data is V / end X is the ingress hairpin queue index.
flow create 1 egress group N pattern eth / meta data is V / end actions vxlan_encap / end
flow create 1 egress group 0 pattern eth / tx_queue index is Y / end actions jump group N / end Y is the egress hairpin queue index. This wildcard flow will help to
redirect all the ethernet packets from hairpin TX queue Y to some
specific group for further handling. In the meanwhile, other traffic
sent from software will not be impacted by this wildcard rule.
To verify this in testpmd, some changes are also required.
1. During startup phase, hairpin binding will use the chaining mode. E.g. if 3 ports are probed, hairpin traffic will be like this port A -> port B, Port B -> port C, port C -> port A In only a single port is probed
port A -> port A
2. flow command line will add support to parse tx queue index pattern format: tx_queue index is UNSIGNED / ...
Thanks
Bing Zhao (4):
ethdev: add support for flow item transmit queue
testpmd: add item transmit queue in flow CLI
ethdev: add hairpin bind APIs
ethdev: add new attributes to hairpin queues config
app/test-pmd/cmdline_flow.c | 18 ++++++ lib/librte_ethdev/rte_ethdev.c | 100 ++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 68 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 ++++++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 30 ++++++++++ 6 files changed, 269 insertions(+)
Signature · 1 line
2.5.5
RFC PATCH v2 1/4 ethdev: add support for flow item transmit queue
New rte_flow_item_tx_queue is introduced to support matching on the traffic from a specific transmit queue. This is only for the egress direction. For ingress, the receive queue index will be part of the actions with ACTION QUEUE or RSS and there is no needs to match.
By adding this flow item, it will be easy for the application to create some wildcard rules to distribute the egress traffic for the further handling.
Normally, all the traffic from software to wire will have the same wildcard rule. If the packets need to be handled in different ways, packets' headers and metadata, etc. will be used for matching.
But in some cases, for example:
1. Packets from different TX queues will have different next common behaviors.
2. Hairpin TX traffic should have different behavior from software egress traffic.
Matching on the TX queue will help to reduce the rules number and simplify the rules management.
The support for this new item will be decided by the PMD driver and the capacity of the NIC.
--- lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
lib/librte_ethdev/rte_flow.c +1 -0
@@ -96,6 +96,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (L2TPV3OIP ,sizeof (struct rte_flow_item_l2tpv3oip )),MK_FLOW_ITEM (PFCP ,sizeof (struct rte_flow_item_pfcp )),MK_FLOW_ITEM (ECPRI ,sizeof (struct rte_flow_item_ecpri )), + MK_FLOW_ITEM(TX_QUEUE, sizeof(struct rte_flow_item_tx_queue)), };/** Generate flow_action[] entry. */
lib/librte_ethdev/rte_flow.h +30 -0
@@ -537,6 +537,13 @@ enum rte_flow_item_type {*/ RTE_FLOW_ITEM_TYPE_ECPRI , +/** +* Matches TX queue ID of a specific port for egress traffic. +* +* See struct rte_flow_item_tx_queue. +*/ + RTE_FLOW_ITEM_TYPE_TX_QUEUE, + };/**
@@ -1580,6 +1587,29 @@ static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {#endif /** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ITEM_TYPE_TX_QUEUE +* +* Match egress traffic originating from a TX queue of a port. Port refers to +* a struct rte_eth_dev object on the application side and the transmit queue +* index must be in the range [0, nb_tx_queue - 1] previously supplied to +* rte_eth_dev_configure(). Normally only supported if the TX queue ID is known +* by the underlying PMD. +*/ +struct rte_flow_item_tx_queue { +uint32_t queue;/**< DPDK TX queue ID of a specific port. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_TX_QUEUE. */ +#ifndef __cplusplus +static const struct rte_flow_item_tx_queue rte_flow_item_tx_queue_mask = { + .queue =0xffffffff , +}; +#endif + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol
Signature · 1 line
2.5.5
RFC PATCH v2 2/4 testpmd: add item transmit queue in flow CLI
In reply to Bing ZhaoIn the testpmd command line for flow creation, add the keyword 'tx_queue' in the pattern scope so the item transmit queue ID could be specified during the flow creation.
The index of the transmit queue should be in the range [0, nb_tx_queue - 1] supplied to rte_eth_dev_configure() during initialization. Normal TX queues and hairpin TX queues will have a unified index number sequence.
--- app/test-pmd/cmdline_flow.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
app/test-pmd/cmdline_flow.c +18 -0
@@ -109,6 +109,8 @@ enum index {ITEM_PHY_PORT_INDEX ,ITEM_PORT_ID ,ITEM_PORT_ID_ID , +ITEM_TX_QUEUE , +ITEM_TX_QUEUE_ID ,ITEM_MARK ,ITEM_MARK_ID , ITEM_RAW,
@@ -759,6 +761,7 @@ static const enum index next_item[] = {ITEM_VF ,ITEM_PHY_PORT ,ITEM_PORT_ID , +ITEM_TX_QUEUE ,ITEM_MARK ,ITEM_RAW , ITEM_ETH,
@@ -1954,6 +1957,21 @@ static const struct token token_list[] = { .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), }, + [ITEM_TX_QUEUE] = { + .name = "tx_queue", + .help = "match traffic from a given transmit queue", + .priv =PRIV_ITEM (QUEUE , + sizeof(struct rte_flow_item_tx_queue)), + .next = NEXT(NEXT_ENTRY(ITEM_TX_QUEUE_ID)), + .call = parse_vc, + }, + [ITEM_TX_QUEUE_ID] = { + .name = "index", + .help = "TX queue index of this port", + .next =NEXT (NEXT_ENTRY (ITEM_NEXT ),NEXT_ENTRY (UNSIGNED ), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tx_queue, queue)), + }, [ITEM_MARK] = { .name = "mark", .help = "match traffic against value set in previously matched rule",
Signature · 1 line
2.5.5
RFC PATCH v2 3/4 ethdev: add hairpin bind APIs
In reply to Bing ZhaoIn single port hairpin mode, all the hairpin TX and RX queues belong to the same device. After the queues are set up properly, there is no other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required for binding will be configured and initialized before.
But in two ports hairpin mode, there will be some cross-dependences between two different ports. Usually, the ports will be initialized serially by the master thread but not in parallel. The earlier port will not be able to enable the bind if the following peer port is not configured done with HW resources. What's more, if one port is detached / attached dynamically, it would introduce more trouble for the hairpin binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set up. Nothing will be done when starting the device if the queues are without auto bind attribute. Only after the required ports pair started, the rte_eth_hairpin_bind() API can be called to bind the all TX queues of the egress port to the RX queues of the peer port. The connection between the egress and ingress ports pair will be established.rte_eth_hairpin_unbind() API could be used to disconnect the egress and the peer ingress ports. This should only be called before the device is closed if needed.
--- lib/librte_ethdev/rte_ethdev.c | 100 ++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 51 +++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 ++++++++++++++++++ 3 files changed, 203 insertions(+)
lib/librte_ethdev/rte_ethdev.c +100 -0
@@ -2175,6 +2175,106 @@ rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id,return eth_err (port_id, ret); } +int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +uint16_t rp; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is not started" , tx_port); +return -EBUSY ; + } + +if (rx_port ==RTE_MAX_ETHPORTS ) { +RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , p); + ret = -EBUSY ; + goto error; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, p); +if (ret) { +RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX " +"%d to RX %d" , tx_port, p); + goto error; + } + } + }else { +RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , rx_port); +return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, rx_port); +if (ret) +RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX %d " +"to RX %d" , tx_port, rx_port); + } + +return ret; + +error: + RTE_ETH_FOREACH_DEV(rp) { +if (rp < p) + (*dev->dev_ops->hairpin_unbind)(dev, rp); + } +return ret; +} + +int +rte_eth_hairpin_unbind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +uint16_t rp; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is stopped" , tx_port); +return -EBUSY ; + } + +if (rx_port ==RTE_MAX_ETHPORTS ) { +RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"RX port %d is stopped" , p); + ret = -EBUSY ; +break ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, p); +if (ret) { +RTE_ETHDEV_LOG (ERR ,"Failed to unbind hairpin " +"TX %d from RX %d" , tx_port, p); +break ; + } + } + }else { +RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"RX port %d is stopped" , rx_port); +return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, rx_port); + } + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)
lib/librte_ethdev/rte_ethdev.h +51 -0
57 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_driver.h +52 -0
64 lines not on this page · raw message
Signature · 1 line
2.5.5
RFC PATCH v2 4/4 ethdev: add new attributes to hairpin queues config
In reply to Bing ZhaoTo support two ports hairpin mode and keep the backward compatibility for application, two new attribute members of hairpin queue config structure are added.
tx_explicit means if PMD or application itself will insert the TX part flow rules.manual_bind means if the hairpin TX queue and peer RX queue will be bound automatically during device start stage.
Different TX and RX queue pairs could have different values, but it is highly recommend that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD driver.
In a single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means no bind API needs to be called and no TX flow rules need to be inserted manually by the application.
--- lib/librte_ethdev/rte_ethdev.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
lib/librte_ethdev/rte_ethdev.h +17 -0
@@ -996,6 +996,21 @@ struct rte_eth_hairpin_cap {#define RTE_ETH_MAX_HAIRPIN_PEERS 32 +/* +* Hairpin queue attribute parameters. +* Each TX queue and peer RX queue should have the same value. +* Default value 0 is for backward-compatibility, the same behaviors should +* remain if the value is not set (0). +*/ +/**< Hairpin queues will be bound automatically */ +#define RTE_ETH_HAIRPIN_BIND_AUTO (0) +/**< Hairpin queues will be bound manually with bind API */ +#define RTE_ETH_HAIRPIN_BIND_MANUAL (1) +/**< Hairpin TX part flow rule will be inserted implicitly by PMD */ +#define RTE_ETH_HAIRPIN_TXRULE_IMPLICIT (0) +/**< Hairpin TX part flow rule will be inserted explicitly by APP */ +#define RTE_ETH_HAIRPIN_TXRULE_EXPLICIT (1) +/** * @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
@@ -1016,6 +1031,8 @@ struct rte_eth_hairpin_peer {struct rte_eth_hairpin_conf {uint16_t peer_count;/**< The number of peers. */ struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; +uint16_t tx_explicit;/**< Explicit TX flow rule by APP. */ +uint16_t manual_bind;/**< Manually binding hairpin queues. */ };/**
Signature · 1 line
2.5.5
cover introduce support for hairpin between two ports
In reply to Bing ZhaoThis patch set will add the support for hairpin between two ports. In the meanwhile, the compatibility of the previous single port mode is taken into consideration and kept.
The patches contain the following changes:
1. new APIs to bind and unbind hairpin ports in manual binding mode.
2. new internal APIs for PMD to pass the queue information and configure the queue pair.
3. new attribute members in the hairpin queue configuraiton structure to specify the binding mode and enable explicit TX flow mode.
4. Testpmd support to configure the hairpin modes for two ports hairpin verification.
Bing Zhao (4):
ethdev: add hairpin bind and unbind APIs
ethdev: add new attributes to hairpin config
ethdev: add APIs for hairpin queue operation
app/testpmd: change hairpin queues setup
app/test-pmd/parameters.c | 15 +++ app/test-pmd/testpmd.c | 68 ++++++++++++- app/test-pmd/testpmd.h | 2 + lib/librte_ethdev/rte_ethdev.c | 162 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 69 +++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 160 ++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 5 + 7 files changed, 477 insertions(+), 4 deletions(-)
Signature · 1 line
2.5.5
PATCH v2 1/4 ethdev: add hairpin bind and unbind APIs
In single port hairpin mode, all the hairpin TX and RX queues belong to the same device. After the queues are set up properly, there is no other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized already for the binding process.
But in two ports hairpin mode, there will be some cross-dependences between two different ports. Usually, the ports will be initialized serially by the main thread but not in parallel. The earlier port will not be able to enable the bind if the following peer port is not yet configured with HW resources. What's more, if one port is detached / attached dynamically, it would introduce more trouble for the hairpin binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set up. Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the rte_eth_hairpin_bind() API can be called to bind the all TX queues of the egress port to the RX queues of the peer port. Then the connection between the egress and ingress ports pair will be established.
The rte_eth_hairpin_unbind() API could be used to disconnect the egress and the peer ingress ports. This should only be called before the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken into consideration.
--- lib/librte_ethdev/rte_ethdev.c | 107 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 51 +++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 +++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 + 4 files changed, 212 insertions(+)
lib/librte_ethdev/rte_ethdev.c +107 -0
@@ -2175,6 +2175,113 @@ rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id,return eth_err (port_id, ret); } +int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +uint16_t rp; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is not started" , tx_port); +return -EBUSY ; + } + +/* +* If the all the ports probed belong to two or more separate NICs, it +* is recommended that each pair is bound independently but not in the +* loop to bind all ports. +*/ +if (rx_port ==RTE_MAX_ETHPORTS ) { +RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , p); + ret = -EBUSY ; + goto unbind; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, p); +if (ret) { +RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX " +"%d to RX %d" , tx_port, p); + goto unbind; + } + } + }else { +RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , rx_port); +return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, rx_port); +if (ret) +RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX %d " +"to RX %d" , tx_port, rx_port); + } + +return ret; + +unbind: +/* Roll back the previous binding process. */ + RTE_ETH_FOREACH_DEV(rp) { +if (rp < p) + (*dev->dev_ops->hairpin_unbind)(dev, rp); +else +break ; + } +return ret; +} + +int +rte_eth_hairpin_unbind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is stopped" , tx_port); +return -EBUSY ; + } + +if (rx_port ==RTE_MAX_ETHPORTS ) { +RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"RX port %d is stopped" , p); + ret = -EBUSY ; +break ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, p); +if (ret) { +RTE_ETHDEV_LOG (ERR ,"Failed to unbind hairpin " +"TX %d from RX %d" , tx_port, p); +break ; + } + } + }else { +RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"RX port %d is stopped" , rx_port); +return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, rx_port); + } + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)
lib/librte_ethdev/rte_ethdev.h +51 -0
57 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_driver.h +52 -0
64 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +2 -0
@@ -227,6 +227,8 @@ EXPERIMENTAL { rte_tm_wred_profile_delete; # added in 20.11 + rte_eth_hairpin_bind; + rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; };
Signature · 1 line
2.5.5
Re: [dpdk-dev] [PATCH 1/4] ethdev: add hairpin bind and unbind APIs
Hi Bing,
PSB,
Thanks,
Ori
Quoted 66 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Cc: [email protected]
Subject: [PATCH 1/4] ethdev: add hairpin bind and unbind APIsIn single port hairpin mode, all the hairpin TX and RX queues belong to the same device. After the queues are set up properly, there is no other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized already for the binding process.
But in two ports hairpin mode, there will be some cross-dependences between two different ports. Usually, the ports will be initialized serially by the main thread but not in parallel. The earlier port will not be able to enable the bind if the following peer port is not yet configured with HW resources. What's more, if one port is detached / attached dynamically, it would introduce more trouble for the hairpin binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set up. Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the
rte_eth_hairpin_bind()API can be called to bind the all TX queues of the egress port to the RX queues of the peer port. Then the connection between the egress and ingress ports pair will be established.The
rte_eth_hairpin_unbind()API could be used to disconnect the egress and the peer ingress ports. This should only be called before the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken into consideration.Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 107 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 51 +++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 +++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 + 4 files changed, 212 insertions(+)lib/librte_ethdev/rte_ethdev.c +11
-0@@ -2175,6 +2175,113 @@ rte_eth_tx_hairpin_queue_setup(uint16_t port_id,uint16_t tx_queue_id, return eth_err(port_id, ret); } +int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +uint16_t rp; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port];
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, · line 2199
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is not started" , tx_port); +return -EBUSY ; + } + +/* +* If the all the ports probed belong to two or more separate NICs, it +* is recommended that each pair is bound independently but not in the +* loop to bind all ports. +*/
I don't understand your comment.
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, · line 2200
Quoted 1 line
lib/librte_ethdev/rte_ethdev.c +1
-0+if (rx_port ==RTE_MAX_ETHPORTS ) {
I think maybe this should be done in the tx queue. Since if the bind don't need some port why do we care if it is started?
So either add a new function to get all peer ports from the tx port, or move this logic to the Target PMD.
Quoted 52 lines
lib/librte_ethdev/rte_ethdev.c +11
-0+RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , p); + ret = -EBUSY ; + goto unbind; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, p); +if (ret) { + RTE_ETHDEV_LOG(ERR, "Failed to bind hairpinTX "
lib/librte_ethdev/rte_ethdev.c +40
-0+ "%d to RX %d", tx_port, p); + goto unbind; + } + } + }else { +RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , rx_port); +return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, rx_port); +if (ret) +RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX %d " +"to RX %d" , tx_port, rx_port); + } + +return ret; + +unbind: +/* Roll back the previous binding process. */ + RTE_ETH_FOREACH_DEV(rp) { +if (rp < p) + (*dev->dev_ops->hairpin_unbind)(dev, rp); +else +break ; + } +return ret; +} + +int +rte_eth_hairpin_unbind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL );
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id, · line 2260
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+ dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is stopped" , tx_port); +return -EBUSY ; + } + +if (rx_port ==RTE_MAX_ETHPORTS ) { +RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) {
This condition should never be true.
First see my comment above about the list of devices, second port should fail to stop if it is bounded.
Quoted 184 lines
lib/librte_ethdev/rte_ethdev.c +1
-0+ RTE_ETHDEV_LOG(ERR, "RX port %d isstopped", p);
lib/librte_ethdev/rte_ethdev.c +6
-0+ ret = -EBUSY ; +break ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, p); +if (ret) { + RTE_ETHDEV_LOG(ERR, "Failed to unbindhairpin "
lib/librte_ethdev/rte_ethdev.c +9
-0+ "TX %d from RX %d", tx_port, p); +break ; + } + } + }else { +RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { + RTE_ETHDEV_LOG(ERR, "RX port %d is stopped",
rx_port);lib/librte_ethdev/rte_ethdev.c +8
-0+return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, rx_port); + } + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)lib/librte_ethdev/rte_ethdev.h +2
-0@@ -2133,6 +2133,57 @@ int rte_eth_tx_hairpin_queue_setup const struct rte_eth_hairpin_conf *conf);/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Bind all hairpin TX queues of one port to the RX queues of the peer port.
+ * It is only allowed to call this API after all hairpin queues are configured
+ * properly and the devices of TX and peer RX are in started state.
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.
+ * @paramrx_port+ * The peer RX port identifier of the Ethernet device. + * RTE_MAX_ETHPORTS is allowed for the traversal of all devices. + * RX port ID could have the same value with TX port ID. + * + * @return + * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is not in started state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.+ */
lib/librte_ethdev/rte_ethdev.h +6
-0+__rte_experimental +int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Unbind all hairpin TX queues of one port from the RX queues of the peer port.
+ * This should be called before closing the TX or RX devices (optional). After
+ * unbind the hairpin ports pair, it is allowed to bind them again.
+ * Changing queues configuration should be after stopping the device.
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.
+ * @paramrx_port+ * The peer RX port identifier of the Ethernet device. + * RTE_MAX_ETHPORTS is allowed for traversal of all devices. + * RX port ID could have the same value with TX port ID. + * + * @return + * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is in stopped state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.+ */
lib/librte_ethdev/rte_ethdev.h +4
-0+__rte_experimental +int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port); + +/** * Return the NUMA socket to which an Ethernet device is connected * * @param port_id lib/librte_ethdev/rte_ethdev_driver.h +26
-0@@ -575,6 +575,54 @@ typedef int (*eth_tx_hairpin_queue_setup_t) const struct rte_eth_hairpin_conf *hairpin_conf);/** +* @internal +* Bind all hairpin TX queues of one port to the RX queues of the peer port. +* +* @param dev +* ethdev handle of port. +* @param rx_port +* the peer RX port. +* +* @return +* Negative errno value on error, 0 on success. +* +* @retval 0 +* Success, bind successfully. +* @retval -ENOTSUP +* Bind API is not supported. +* @retval -EINVAL +* One of the parameters is invalid. +* @retval -EBUSY +* Device is not started. +*/ +typedef int (*eth_hairpin_bind_t )(struct rte_eth_dev *dev, +uint16_t rx_port); + +/** +* @internal +* Unbind all hairpin TX queues of one port from the RX queues of the peer port.
+ *
+ * @param dev
+ * ethdev handle of port.
+ * @paramrx_port
+ * the peer RX port.
+ *
+ * @return
+ * Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ * Success, bind successfully.
+ * @retval-ENOTSUP
+ * Bind API is not supported.
+ * @retval-EINVAL
+ * One of the parameters is invalid.
+ * @retval-EBUSY
+ * Device is already stopped.
+ */lib/librte_ethdev/rte_ethdev_driver.h +4
-0+typedef int (*eth_hairpin_unbind_t )(struct rte_eth_dev *dev, +uint16_t rx_port); + +/** * @internal A structure containing the functions exported by an Ethernet driver.
*/
structeth_dev_ops{lib/librte_ethdev/rte_ethdev_driver.h +4
-0@@ -713,6 +761,10 @@ struct eth_dev_ops {/**< Set up device RX hairpin queue. */ eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;/**< Set up device TX hairpin queue. */ +eth_hairpin_bind_t hairpin_bind; +/**< Bind all hairpin TX queues of device to the peer port RX queues. */ +eth_hairpin_unbind_t hairpin_unbind; +/**< Unbind all hairpin TX queues from the peer port RX queues. */ };/** lib/librte_ethdev/rte_ethdev_version.map +2
-1@@ -227,6 +227,8 @@ EXPERIMENTAL { rte_tm_wred_profile_delete; # added in 20.11 + rte_eth_hairpin_bind; + rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; }; --2.5.5
Re: [dpdk-dev] [PATCH 1/4] ethdev: add hairpin bind and unbind APIs
Hi Ori,
Quoted 105 lines
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Sunday, October 4, 2020 5:20 PM
To: Bing Zhao <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]
Subject: RE: [PATCH 1/4] ethdev: add hairpin bind and unbind APIsHi Bing,
PSB,
Thanks,
OriQuoted 7 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Cc: [email protected]
Subject: [PATCH 1/4] ethdev: add hairpin bind and unbind APIsIn single port hairpin mode, all the hairpin TX and RX queues
belong
Quoted 1 line
to the same device. After the queues are set up properly, there is
no
Quoted 4 lines
other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized
already
Quoted 3 lines
for the binding process.
But in two ports hairpin mode, there will be some cross-
dependences
Quoted 1 line
between two different ports. Usually, the ports will be
initialized
Quoted 1 line
serially by the main thread but not in parallel. The earlier port
will
Quoted 1 line
not be able to enable the bind if the following peer port is not
yet
Quoted 1 line
configured with HW resources. What's more, if one port is detached
/
Quoted 1 line
attached dynamically, it would introduce more trouble for the
hairpin
Quoted 4 lines
binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set
up.
Quoted 3 lines
Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the
rte_eth_hairpin_bind()API can be called to bindthe
Quoted 2 lines
all TX queues of the egress port to the RX queues of the peer port. Then the connection between the egress and ingress ports pair will
be
Quoted 4 lines
established.
The
rte_eth_hairpin_unbind()API could be used to disconnect the egress and the peer ingress ports. This should only be calledbefore
Quoted 2 lines
the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken
into
Quoted 22 lines
consideration.
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 107 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 51 +++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 +++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 + 4 files changed, 212 insertions(+)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_ethdev.cindex dfe5c1b..72f567b 100644lib/librte_ethdev/rte_ethdev.c +2
-0@@ -2175,6 +2175,113 @@ rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id, return eth_err(port_id, ret); } +int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) {lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t · line 2190
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +uint16_t rp; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { + RTE_ETHDEV_LOG(ERR, "TX port %d is not started",
tx_port);lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5
-0+return -EBUSY ; + } + +/* +* If the all the ports probed belong to two or more separate NICs, it
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t · line 2196
Quoted 1 line
lib/librte_ethdev/rte_ethdev.c +1
-0+* is recommended that each pair is bound independently but not in the
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id, · line 2198
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +2
-0+* loop to bind all ports. +*/ I don't understand your comment.
I mean, in the following loops, if the application wants to bind one TX port to all the other RX ports, it would not be supported between different PMDs or different NICs. Then the roll-back actions will be done and no hairpin port peers will work successfully.
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t · line 2199
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +1
-0+if (rx_port ==RTE_MAX_ETHPORTS ) {I think maybe this should be done in the tx queue. Since if the bind don't need some port why do we care if it is started?
Do you mean the checking in the RX ports loop below? At first, I intended to make sure this API would be called only after all the ports are started. But yes, there is no need if some port is not being used.
Quoted 2 lines
So either add a new function to get all peer ports from the tx port, or move this logic to the Target PMD.
There would be one more API to be introduced. To my understanding, it would be more appropriate if we add a new API here. But it would keep RTE simpler if we move such logic into the PMD.
Quoted 59 lines
Quoted 18 lines
lib/librte_ethdev/rte_ethdev.c +11
-0+RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , p); + ret = -EBUSY ; + goto unbind; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, p); +if (ret) { + RTE_ETHDEV_LOG(ERR, "Failed to bind hairpinTX "
lib/librte_ethdev/rte_ethdev.c +5
-0+ "%d to RX %d", tx_port, p); + goto unbind; + } + } + }else {lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , rx_port); +return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, rx_port); +if (ret) + RTE_ETHDEV_LOG(ERR, "Failed to bind hairpin TX %d"
Quoted 30 lines
lib/librte_ethdev/rte_ethdev.c +30
-0+ "to RX %d", tx_port, rx_port); + } + +return ret; + +unbind: +/* Roll back the previous binding process. */ + RTE_ETH_FOREACH_DEV(rp) { +if (rp < p) + (*dev->dev_ops->hairpin_unbind)(dev, rp); +else +break ; + } +return ret; +} + +int +rte_eth_hairpin_unbind (uint16_t tx_port,uint16_t rx_port) { +struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is stopped" , tx_port); +return -EBUSY ; + } +
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id, · line 2202
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+if (rx_port ==RTE_MAX_ETHPORTS ) { +RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) {This condition should never be true.
First see my comment above about the list of devices, second port should fail to stop if it is bounded.
Thank, I will remove this check and make the logic the same as "bind" API.
When stopping the second port, PMD will check if any peer port is bound and return a failure then.
Quoted 195 lines
Quoted 20 lines
lib/librte_ethdev/rte_ethdev.c +1
-0+ RTE_ETHDEV_LOG(ERR, "RX port %d isstopped", p);
lib/librte_ethdev/rte_ethdev.c +6
-0+ ret = -EBUSY ; +break ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, p); +if (ret) { + RTE_ETHDEV_LOG(ERR, "Failed to unbindhairpin "
lib/librte_ethdev/rte_ethdev.c +9
-0+ "TX %d from RX %d", tx_port, p); +break ; + } + } + }else { +RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { + RTE_ETHDEV_LOG(ERR, "RX port %d is stopped",
rx_port);lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +8
-0+return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, rx_port); + } + +return ret; +} +void rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_tunsent,
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_hairpin_queue_setup · line 2137
Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +0
-0void *userdata __rte_unused)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_ethdev.hindex 645a186..c3fb684 100644lib/librte_ethdev/rte_ethdev.h +2
-0@@ -2133,6 +2133,57 @@ int rte_eth_tx_hairpin_queue_setup const struct rte_eth_hairpin_conf *conf);/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 3 lines
notice
+ *
+ * Bind all hairpin TX queues of one port to the RX queues of thepeer port.
Quoted 1 line
+ * It is only allowed to call this API after all hairpin queues
are
Quoted 2 lines
+configured
+ * properly and the devices of TX and peer RX are in startedstate.
Quoted 15 lines
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.
+ * @paramrx_port+ * The peer RX port identifier of the Ethernet device. + * RTE_MAX_ETHPORTS is allowed for the traversal of all devices. + * RX port ID could have the same value with TX port ID. + * + * @return + * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is not in started state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.+ */
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_hairpin_queue_setup
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +6
-0+__rte_experimental +int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 3 lines
notice
+ *
+ * Unbind all hairpin TX queues of one port from the RX queues ofthe
Quoted 5 lines
+ peer
port.
+ * This should be called before closing the TX or RX devices +(optional). After
+ * unbind the hairpin ports pair, it is allowed to bind themagain.
Quoted 1 line
+ * Changing queues configuration should be after stopping the
device.
Quoted 15 lines
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.
+ * @paramrx_port+ * The peer RX port identifier of the Ethernet device. + * RTE_MAX_ETHPORTS is allowed for traversal of all devices. + * RX port ID could have the same value with TX port ID. + * + * @return + * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is in stopped state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.+ */
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_hairpin_queue_setup
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +4
-0+__rte_experimental +int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port); + +/** * Return the NUMA socket to which an Ethernet device is connected
lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 579
Quoted 13 lines
*
* @paramport_idlib/librte_ethdev/rte_ethdev_driver.h +2
-0@@ -575,6 +575,54 @@ typedef int (*eth_tx_hairpin_queue_setup_t) const struct rte_eth_hairpin_conf *hairpin_conf);/** +* @internal +* Bind all hairpin TX queues of one port to the RX queues of the peer port.
Quoted 14 lines
lib/librte_ethdev/rte_ethdev_driver.h +14
-0+* +* @param dev +* ethdev handle of port. +* @param rx_port +* the peer RX port. +* +* @return +* Negative errno value on error, 0 on success. +* +* @retval 0 +* Success, bind successfully. +* @retval -ENOTSUP +* Bind API is not supported. +* @retval -EINVAL lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t)
Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10
-0+* One of the parameters is invalid. +* @retval -EBUSY +* Device is not started. +*/ +typedef int (*eth_hairpin_bind_t )(struct rte_eth_dev *dev, +uint16_t rx_port); + +/** +* @internal +* Unbind all hairpin TX queues of one port from the RX queues of the
Quoted 29 lines
lib/librte_ethdev/rte_ethdev_driver.h +1
-0+peerport.
+ *
+ * @param dev
+ * ethdev handle of port.
+ * @paramrx_port
+ * the peer RX port.
+ *
+ * @return
+ * Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ * Success, bind successfully.
+ * @retval-ENOTSUP
+ * Bind API is not supported.
+ * @retval-EINVAL
+ * One of the parameters is invalid.
+ * @retval-EBUSY
+ * Device is already stopped.
+ */lib/librte_ethdev/rte_ethdev_driver.h +4
-0+typedef int (*eth_hairpin_unbind_t )(struct rte_eth_dev *dev, +uint16_t rx_port); + +/** * @internal A structure containing the functions exported by an Ethernet driver.
*/
structeth_dev_ops{lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 765
Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +2
-0@@ -713,6 +761,10 @@ struct eth_dev_ops {/**< Set up device RX hairpin queue. */ eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;/**< Set up device TX hairpin queue. */ +eth_hairpin_bind_t hairpin_bind; +/**< Bind all hairpin TX queues of device to the peer port RX queues. */
lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 767
Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2
-0+eth_hairpin_unbind_t hairpin_unbind; +/**< Unbind all hairpin TX queues from the peer port RX queues. */
Quoted 11 lines
lib/librte_ethdev/rte_ethdev_driver.h +0
-0};/** lib/librte_ethdev/rte_ethdev_version.map +0
-0@@ -227,6 +227,8 @@ EXPERIMENTAL { rte_tm_wred_profile_delete;
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_ethdev_version.map +2
-1# added in 20.11 + rte_eth_hairpin_bind; + rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; }; --2.5.5
Thanks
Re: [dpdk-dev] [PATCH 1/4] ethdev: add hairpin bind and unbind APIs
Hi Bing,
Quoted 113 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Wednesday, October 7, 2020 2:22 PM
Subject: RE: [PATCH 1/4] ethdev: add hairpin bind and unbind APIsHi Ori,
Quoted 99 lines
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Sunday, October 4, 2020 5:20 PM
Subject: RE: [PATCH 1/4] ethdev: add hairpin bind and unbind APIsHi Bing,
PSB,
Thanks,
OriQuoted 7 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Cc: [email protected]
Subject: [PATCH 1/4] ethdev: add hairpin bind and unbind APIsIn single port hairpin mode, all the hairpin TX and RX queues
belong
Quoted 1 line
to the same device. After the queues are set up properly, there is
no
Quoted 4 lines
other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized
already
Quoted 3 lines
for the binding process.
But in two ports hairpin mode, there will be some cross-
dependences
Quoted 1 line
between two different ports. Usually, the ports will be
initialized
Quoted 1 line
serially by the main thread but not in parallel. The earlier port
will
Quoted 1 line
not be able to enable the bind if the following peer port is not
yet
Quoted 1 line
configured with HW resources. What's more, if one port is detached
/
Quoted 1 line
attached dynamically, it would introduce more trouble for the
hairpin
Quoted 4 lines
binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set
up.
Quoted 3 lines
Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the
rte_eth_hairpin_bind()API can be called to bindthe
Quoted 2 lines
all TX queues of the egress port to the RX queues of the peer port. Then the connection between the egress and ingress ports pair will
be
Quoted 4 lines
established.
The
rte_eth_hairpin_unbind()API could be used to disconnect the egress and the peer ingress ports. This should only be calledbefore
Quoted 2 lines
the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken
into
Quoted 22 lines
consideration.
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 107 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 51 +++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 +++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 + 4 files changed, 212 insertions(+)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_ethdev.cindex dfe5c1b..72f567b 100644lib/librte_ethdev/rte_ethdev.c +2
-0@@ -2175,6 +2175,113 @@ rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id, return eth_err(port_id, ret); } +int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) {lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t · line 2190
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +uint16_t rp; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { + RTE_ETHDEV_LOG(ERR, "TX port %d is not started",
tx_port);lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5
-0+return -EBUSY ; + } + +/* +* If the all the ports probed belong to two or more separate NICs, it
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t · line 2196
Quoted 1 line
lib/librte_ethdev/rte_ethdev.c +1
-0+* is recommended that each pair is bound independently but not in the
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id, · line 2198
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +2
-0+* loop to bind all ports. +*/ I don't understand your comment.
Quoted 5 lines
I mean, in the following loops, if the application wants to bind one TX port to all the other RX ports, it would not be supported between different PMDs or different NICs. Then the roll-back actions will be done and no hairpin port peers will work successfully.
O.K.
Quoted 10 lines
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t · line 2199
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +1
-0+if (rx_port ==RTE_MAX_ETHPORTS ) {I think maybe this should be done in the tx queue. Since if the bind don't need some port why do we care if it is started?
Do you mean the checking in the RX ports loop below? At first, I intended to make sure this API would be called only after all the ports are started. But yes, there is no need if some port is not being used.
I mean move the check to the tx pmd, if for some reason (peer device not started) then it should fail.
Quoted 7 lines
Quoted 2 lines
So either add a new function to get all peer ports from the tx port, or move this logic to the Target PMD.
There would be one more API to be introduced. To my understanding, it would be more appropriate if we add a new API here.
But it would keep RTE simpler if we move such logic into the PMD.
I'm fine with moving the logic to the PMD as long as it can check the status. which he can using the internal function right?
Quoted 68 lines
Quoted 59 lines
Quoted 18 lines
lib/librte_ethdev/rte_ethdev.c +11
-0+RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , p); + ret = -EBUSY ; + goto unbind; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, p); +if (ret) { + RTE_ETHDEV_LOG(ERR, "Failed to bind hairpinTX "
lib/librte_ethdev/rte_ethdev.c +5
-0+ "%d to RX %d", tx_port, p); + goto unbind; + } + } + }else {lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { +RTE_ETHDEV_LOG (ERR , +"RX port %d is not started" , rx_port); +return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_bind)(dev, rx_port); +if (ret) + RTE_ETHDEV_LOG(ERR, "Failed to bind hairpin TX %d"
Quoted 30 lines
lib/librte_ethdev/rte_ethdev.c +30
-0+ "to RX %d", tx_port, rx_port); + } + +return ret; + +unbind: +/* Roll back the previous binding process. */ + RTE_ETH_FOREACH_DEV(rp) { +if (rp < p) + (*dev->dev_ops->hairpin_unbind)(dev, rp); +else +break ; + } +return ret; +} + +int +rte_eth_hairpin_unbind (uint16_t tx_port,uint16_t rx_port) { +struct rte_eth_dev *dev; +struct rte_eth_dev *rdev; +uint16_t p; +int ret =0 ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is stopped" , tx_port); +return -EBUSY ; + } +Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id, · line 2202
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+if (rx_port ==RTE_MAX_ETHPORTS ) { +RTE_ETH_FOREACH_DEV (p) { + rdev = &rte_eth_devices[p]; +if (!rdev->data->dev_started) {This condition should never be true.
First see my comment above about the list of devices, second port should fail to stop if it is bounded.
Quoted 4 lines
Thank, I will remove this check and make the logic the same as "bind" API. When stopping the second port, PMD will check if any peer port is bound and return a failure then.
Great we should also consider what happens in case of hot plug, In this case the hot plug port should be able to unbind himself from all ports.
Quoted 205 lines
Quoted 195 lines
Quoted 20 lines
lib/librte_ethdev/rte_ethdev.c +1
-0+ RTE_ETHDEV_LOG(ERR, "RX port %d isstopped", p);
lib/librte_ethdev/rte_ethdev.c +6
-0+ ret = -EBUSY ; +break ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, p); +if (ret) { + RTE_ETHDEV_LOG(ERR, "Failed to unbindhairpin "
lib/librte_ethdev/rte_ethdev.c +9
-0+ "TX %d from RX %d", tx_port, p); +break ; + } + } + }else { +RTE_ETH_VALID_PORTID_OR_ERR_RET (rx_port, -EINVAL ); + rdev = &rte_eth_devices[rx_port]; +if (!rdev->data->dev_started) { + RTE_ETHDEV_LOG(ERR, "RX port %d is stopped",
rx_port);lib/librte_ethdev/rte_ethdev.c rte_eth_tx_hairpin_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +8
-0+return -EBUSY ; + } + ret = (*dev->dev_ops->hairpin_unbind)(dev, rx_port); + } + +return ret; +} +void rte_eth_tx_buffer_drop_callback(struct rte_mbuf **pkts, uint16_tunsent,
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_hairpin_queue_setup · line 2137
Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +0
-0void *userdata __rte_unused)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_ethdev.hindex 645a186..c3fb684 100644lib/librte_ethdev/rte_ethdev.h +2
-0@@ -2133,6 +2133,57 @@ int rte_eth_tx_hairpin_queue_setup const struct rte_eth_hairpin_conf *conf);/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 3 lines
notice
+ *
+ * Bind all hairpin TX queues of one port to the RX queues of thepeer port.
Quoted 1 line
+ * It is only allowed to call this API after all hairpin queues
are
Quoted 2 lines
+configured
+ * properly and the devices of TX and peer RX are in startedstate.
Quoted 15 lines
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.
+ * @paramrx_port+ * The peer RX port identifier of the Ethernet device. + * RTE_MAX_ETHPORTS is allowed for the traversal of all devices. + * RX port ID could have the same value with TX port ID. + * + * @return + * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is not in started state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.+ */
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_hairpin_queue_setup
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +6
-0+__rte_experimental +int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 3 lines
notice
+ *
+ * Unbind all hairpin TX queues of one port from the RX queues ofthe
Quoted 5 lines
+ peer
port.
+ * This should be called before closing the TX or RX devices +(optional). After
+ * unbind the hairpin ports pair, it is allowed to bind themagain.
Quoted 1 line
+ * Changing queues configuration should be after stopping the
device.
Quoted 15 lines
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.
+ * @paramrx_port+ * The peer RX port identifier of the Ethernet device. + * RTE_MAX_ETHPORTS is allowed for traversal of all devices. + * RX port ID could have the same value with TX port ID. + * + * @return + * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is in stopped state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.+ */
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_hairpin_queue_setup
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +4
-0+__rte_experimental +int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port); + +/** * Return the NUMA socket to which an Ethernet device is connected
lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t) · line 579
Quoted 13 lines
*
* @paramport_idlib/librte_ethdev/rte_ethdev_driver.h +2
-0@@ -575,6 +575,54 @@ typedef int (*eth_tx_hairpin_queue_setup_t) const struct rte_eth_hairpin_conf *hairpin_conf);/** +* @internal +* Bind all hairpin TX queues of one port to the RX queues of the peer port.
Quoted 14 lines
lib/librte_ethdev/rte_ethdev_driver.h +14
-0+* +* @param dev +* ethdev handle of port. +* @param rx_port +* the peer RX port. +* +* @return +* Negative errno value on error, 0 on success. +* +* @retval 0 +* Success, bind successfully. +* @retval -ENOTSUP +* Bind API is not supported. +* @retval -EINVAL lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_tx_hairpin_queue_setup_t)
Quoted 10 lines
lib/librte_ethdev/rte_ethdev_driver.h +10
-0+* One of the parameters is invalid. +* @retval -EBUSY +* Device is not started. +*/ +typedef int (*eth_hairpin_bind_t )(struct rte_eth_dev *dev, +uint16_t rx_port); + +/** +* @internal +* Unbind all hairpin TX queues of one port from the RX queues of the
Quoted 29 lines
lib/librte_ethdev/rte_ethdev_driver.h +1
-0+peerport.
+ *
+ * @param dev
+ * ethdev handle of port.
+ * @paramrx_port
+ * the peer RX port.
+ *
+ * @return
+ * Negative errno value on error, 0 on success.
+ *
+ * @retval 0
+ * Success, bind successfully.
+ * @retval-ENOTSUP
+ * Bind API is not supported.
+ * @retval-EINVAL
+ * One of the parameters is invalid.
+ * @retval-EBUSY
+ * Device is already stopped.
+ */lib/librte_ethdev/rte_ethdev_driver.h +4
-0+typedef int (*eth_hairpin_unbind_t )(struct rte_eth_dev *dev, +uint16_t rx_port); + +/** * @internal A structure containing the functions exported by an Ethernet driver.
*/
structeth_dev_ops{lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 765
Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +2
-0@@ -713,6 +761,10 @@ struct eth_dev_ops {/**< Set up device RX hairpin queue. */ eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;/**< Set up device TX hairpin queue. */ +eth_hairpin_bind_t hairpin_bind; +/**< Bind all hairpin TX queues of device to the peer port RX queues. */
lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 767
Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +2
-0+eth_hairpin_unbind_t hairpin_unbind; +/**< Unbind all hairpin TX queues from the peer port RX queues. */
Quoted 11 lines
lib/librte_ethdev/rte_ethdev_driver.h +0
-0};/** lib/librte_ethdev/rte_ethdev_version.map +0
-0@@ -227,6 +227,8 @@ EXPERIMENTAL { rte_tm_wred_profile_delete;Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_ethdev_version.map +2
-1# added in 20.11 + rte_eth_hairpin_bind; + rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; }; --2.5.5
Thanks
PATCH v2 2/4 ethdev: add new attributes to hairpin config
In reply to Bing ZhaoTo support two ports hairpin mode and keep the backward compatibility for the application, two new attribute members of hairpin queue config structure are added.
tx_explicit means if the application itself will insert the TX part flow rules. If not set, PMD will insert the rules implicitly. manual_bind means if the hairpin TX queue and peer RX queue will be bound automatically during device start stage.
Different TX and RX queue pairs could have different values, but it is highly recommend that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD driver.
In a single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means no bind API needs to be called and no TX flow rules need to be inserted manually by the application.
--- lib/librte_ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
lib/librte_ethdev/rte_ethdev.h +18 -0
@@ -1027,6 +1027,21 @@ struct rte_eth_hairpin_cap {#define RTE_ETH_MAX_HAIRPIN_PEERS 32 +/* +* Hairpin queue attribute parameters. +* Each TX queue and peer RX queue should have the same value. +* Default value 0 is for backward-compatibility, the same behaviors should +* remain if the value is not set (0). +*/ +/**< Hairpin queues will be bound automatically */ +#define RTE_ETH_HAIRPIN_BIND_AUTO (0) +/**< Hairpin queues will be bound manually with bind API */ +#define RTE_ETH_HAIRPIN_BIND_MANUAL (1) +/**< Hairpin TX part flow rule will be inserted implicitly by PMD */ +#define RTE_ETH_HAIRPIN_TXRULE_IMPLICIT (0) +/**< Hairpin TX part flow rule will be inserted explicitly by APP */ +#define RTE_ETH_HAIRPIN_TXRULE_EXPLICIT (1) +/** * @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
@@ -1046,6 +1061,9 @@ struct rte_eth_hairpin_peer {*/ struct rte_eth_hairpin_conf {uint16_t peer_count;/**< The number of peers. */ +uint32_t reserved :30 ;/**< Reserved bits. */ +uint32_t tx_explicit :1 ;/**< Explicit TX flow rule mode. */ +uint32_t manual_bind :1 ;/**< Manually bind hairpin queues. */ struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; };
Signature · 1 line
2.5.5
Re: [dpdk-dev] [PATCH 2/4] ethdev: add new attributes to hairpin config
Hi Bing,
PSB,
Best,
Ori
Quoted 43 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Subject: [PATCH 2/4] ethdev: add new attributes to hairpin configTo support two ports hairpin mode and keep the backward compatibility for the application, two new attribute members of hairpin queue config structure are added.
tx_explicitmeans if the application itself will insert the TX part flow rules. If not set, PMD will insert the rules implicitly.manual_bindmeans if the hairpin TX queue and peer RX queue will be bound automatically during device start stage.Different TX and RX queue pairs could have different values, but it is highly recommend that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD driver.
In a single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means no bind API needs to be called and no TX flow rules need to be inserted manually by the application.
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)lib/librte_ethdev/rte_ethdev.h +5
-0@@ -1027,6 +1027,21 @@ struct rte_eth_hairpin_cap {#define RTE_ETH_MAX_HAIRPIN_PEERS 32 +/* +* Hairpin queue attribute parameters. +* Each TX queue and peer RX queue should have the same value. +* Default value 0 is for backward-compatibility, the same behaviors should +* remain if the value is not set (0).
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_cap { · line 1044
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.h +10
-0+*/ +/**< Hairpin queues will be bound automatically */ +#define RTE_ETH_HAIRPIN_BIND_AUTO (0) +/**< Hairpin queues will be bound manually with bind API */ +#define RTE_ETH_HAIRPIN_BIND_MANUAL (1) +/**< Hairpin TX part flow rule will be inserted implicitly by PMD */ +#define RTE_ETH_HAIRPIN_TXRULE_IMPLICIT (0) +/**< Hairpin TX part flow rule will be inserted explicitly by APP */ +#define RTE_ETH_HAIRPIN_TXRULE_EXPLICIT (1) +
Why do you need those defines if you are using bit fields?
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer { · line 1066
Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +0
-0/** * @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
lib/librte_ethdev/rte_ethdev.h +3
-0@@ -1046,6 +1061,9 @@ struct rte_eth_hairpin_peer {*/ struct rte_eth_hairpin_conf {uint16_t peer_count;/**< The number of peers. */ +uint32_t reserved :30 ;/**< Reserved bits. */ +uint32_t tx_explicit :1 ;/**< Explicit TX flow rule mode. */ +uint32_t manual_bind :1 ;/**< Manually bind hairpin queues. */
Why not place the new bits at the end?
Also why do you place the reserved first?
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.h +0
-1struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; }; --2.5.5
Re: [dpdk-dev] [PATCH 2/4] ethdev: add new attributes to hairpin config
Hi Ori,
Quoted 78 lines
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Sunday, October 4, 2020 5:22 PM
To: Bing Zhao <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]
Subject: RE: [PATCH 2/4] ethdev: add new attributes to hairpin configHi Bing,
PSB,
Best,
OriQuoted 6 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Subject: [PATCH 2/4] ethdev: add new attributes to hairpin configTo support two ports hairpin mode and keep the backward
compatibility
Quoted 1 line
for the application, two new attribute members of hairpin queue
config
Quoted 3 lines
structure are added.
tx_explicitmeans if the application itself will insert the TXpart
Quoted 2 lines
flow rules. If not set, PMD will insert the rules implicitly.
manual_bindmeans if the hairpin TX queue and peer RX queue willbe
Quoted 3 lines
bound automatically during device start stage.
Different TX and RX queue pairs could have different values, but
it is
Quoted 3 lines
highly recommend that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute
parameters
Quoted 3 lines
will be checked and decided by the PMD driver.
In a single port hairpin, if both are zero without any setting,
the
Quoted 1 line
behavior will remain the same as before. It means no bind API
needs to
Quoted 13 lines
be called and no TX flow rules need to be inserted manually by the application.
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_ethdev.hindex c3fb684..0cabff0 100644lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_cap { · line 1033
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.h +4
-0@@ -1027,6 +1027,21 @@ struct rte_eth_hairpin_cap {#define RTE_ETH_MAX_HAIRPIN_PEERS 32 +/* +* Hairpin queue attribute parameters. +* Each TX queue and peer RX queue should have the same value. +* Default value 0 is for backward-compatibility, the same behaviors
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_cap {
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h +8
-0+should +* remain if the value is not set (0). +*/ +/**< Hairpin queues will be bound automatically */ +#define RTE_ETH_HAIRPIN_BIND_AUTO (0) +/**< Hairpin queues will be bound manually with bind API */ +#define RTE_ETH_HAIRPIN_BIND_MANUAL (1) +/**< Hairpin TX part flow rule will be inserted implicitly by PMD */
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_cap { · line 1043
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2
-0+#define RTE_ETH_HAIRPIN_TXRULE_IMPLICIT (0) +/**< Hairpin TX part flow rule will be inserted explicitly by APP */
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_cap { · line 1044
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2
-0+#define RTE_ETH_HAIRPIN_TXRULE_EXPLICIT (1) +Why do you need those defines if you are using bit fields?
I will remove this and add the description of the modes in the document.
Quoted 14 lines
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_cap {
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +0
-0/** * @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer {
Quoted 7 lines
notice @@ -1046,6 +1061,9 @@ struct
rte_eth_hairpin_peer{
*/
structrte_eth_hairpin_conf{lib/librte_ethdev/rte_ethdev.h +3
-0uint16_t peer_count;/**< The number of peers. */ + uint32_t reserved : 30; /**< Reserved bits. */ + uint32_t tx_explicit : 1; /**< Explicit TX flow rule mode. */ + uint32_t manual_bind : 1; /**< Manually bind hairpin queues.*/
Quoted 1 line
Why not place the new bits at the end?
By using uint16_t bit fields, there will be some warnings by the compiler and it is not standard. I prefer to change the "uint16_t peer_count" into "uint32_t peer_count:16" to use the gap before the next structure. Or yes, I can move it to the end of this current structure.
Quoted 1 line
Also why do you place the reserved first?
Thanks, I will move it to the end of the u32 like other structure definitions.
Quoted 6 lines
Quoted 2 lines
struct
rte_eth_hairpin_peerpeers[RTE_ETH_MAX_HAIRPIN_PEERS]; };
Quoted 3 lines
--
2.5.5
Thanks
PATCH v2 3/4 ethdev: add APIs for hairpin queue operation
In reply to Bing ZhaoEvery hairpin queue pair should be configured properly and the connection between TX and RX queues should be established, before hairpin function works. In single port hairpin mode, the queues of each pair belong to the same device. It is easy to get the hardware and software information of each queue and configure the hairpin connection with such information. In two ports hairpin mode, it is not easy or inappropriate to access one queue's information from another device.
Since hairpin is configured per queue pair, three new APIs are introduced and they are internal for the PMD using.
The peer update API helps to pass one queue's information to the peer queue and get the peer's information back for the next step. The peer bind API configures the current queue with the peer's information. For each hairpin queue pair, this API may need to be called twice to configure the TX, RX queues separately. The peer unbind API resets the current queue configuraion and state to disconnect it from the peer queue. Also, it may need to be called twice to disconnect TX, RX queues from each other.
Some parameter of the above APIs might not be mandatory, and it depends on the PMD implementation.
The structure of rte_hairpin_peer_info is only a declaration and the actual members will be defined in each PMD when being used.
--- lib/librte_ethdev/rte_ethdev.c | 55 ++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 108 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 3 files changed, 166 insertions(+)
lib/librte_ethdev/rte_ethdev.c +55 -0
@@ -5515,6 +5515,61 @@ handle_port_link_status(const char *cmd __rte_unused,return 0 ; } +int +rte_eth_hairpin_queue_peer_update (uint16_t peer_port,uint16_t peer_queue, +struct rte_hairpin_peer_info *cur_info, +struct rte_hairpin_peer_info *peer_info, +bool direction) +{ +struct rte_eth_dev *dev; + +/* Current queue information is not mandatory. */ +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[peer_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_update, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_update)(dev, peer_queue, + cur_info, peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_bind (uint16_t cur_port,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info, +bool direction) +{ +struct rte_eth_dev *dev; + +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_bind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_bind)(dev, cur_queue, + peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_unbind (uint16_t cur_port,uint16_t cur_queue, +bool direction) +{ +struct rte_eth_dev *dev; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_bind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_unbind)(dev, cur_queue, + direction); +} +RTE_LOG_REGISTER (rte_eth_dev_logtype, lib.ethdev,INFO );RTE_INIT (ethdev_init_telemetry)
lib/librte_ethdev/rte_ethdev_driver.h +108 -0
132 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -250,6 +250,9 @@ INTERNAL { rte_eth_devargs_parse; rte_eth_dma_zone_free; rte_eth_dma_zone_reserve; + rte_eth_hairpin_queue_peer_bind; + rte_eth_hairpin_queue_peer_unbind; + rte_eth_hairpin_queue_peer_update; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; rte_flow_expand_rss;
Signature · 1 line
2.5.5
Re: [dpdk-dev] [PATCH 3/4] ethdev: add APIs for hairpin queue operation
Hi Bing,
PSB
Best,
Ori
Quoted 171 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Subject: [PATCH 3/4] ethdev: add APIs for hairpin queue operationEvery hairpin queue pair should be configured properly and the connection between TX and RX queues should be established, before hairpin function works. In single port hairpin mode, the queues of each pair belong to the same device. It is easy to get the hardware and software information of each queue and configure the hairpin connection with such information. In two ports hairpin mode, it is not easy or inappropriate to access one queue's information from another device.
Since hairpin is configured per queue pair, three new APIs are introduced and they are internal for the PMD using.
The peer update API helps to pass one queue's information to the peer queue and get the peer's information back for the next step. The peer bind API configures the current queue with the peer's information. For each hairpin queue pair, this API may need to be called twice to configure the TX, RX queues separately. The peer unbind API resets the current queue configuraion and state to disconnect it from the peer queue. Also, it may need to be called twice to disconnect TX, RX queues from each other.
Some parameter of the above APIs might not be mandatory, and it depends on the PMD implementation.
The structure of
rte_hairpin_peer_infois only a declaration and the actual members will be defined in each PMD when being used.Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 55 ++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 108 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 3 files changed, 166 insertions(+)lib/librte_ethdev/rte_ethdev.c +18
-0@@ -5515,6 +5515,61 @@ handle_port_link_status(const char *cmd __rte_unused, return 0; } +int +rte_eth_hairpin_queue_peer_update (uint16_t peer_port,uint16_t peer_queue, +struct rte_hairpin_peer_info *cur_info, +struct rte_hairpin_peer_info *peer_info, +bool direction) +{ +struct rte_eth_dev *dev; + +/* Current queue information is not mandatory. */ +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[peer_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops- >hairpin_queue_peer_update, + -ENOTSUP ); + + return (*dev->dev_ops->hairpin_queue_peer_update)(dev,
peer_queue,lib/librte_ethdev/rte_ethdev.c +16
-0+ cur_info, peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_bind (uint16_t cur_port,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info, +bool direction) +{ +struct rte_eth_dev *dev; + +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-Quoted 1 line
hairpin_queue_peer_bind,lib/librte_ethdev/rte_ethdev.c +15
-0+ -ENOTSUP); + +return (*dev->dev_ops->hairpin_queue_peer_bind)(dev, cur_queue, + peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_unbind (uint16_t cur_port,uint16_t cur_queue, +bool direction) +{ +struct rte_eth_dev *dev; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-Quoted 1 line
hairpin_queue_peer_bind,lib/librte_ethdev/rte_ethdev.c +6
-0+ -ENOTSUP); + +return (*dev->dev_ops->hairpin_queue_peer_unbind)(dev, cur_queue, + direction); +} +RTE_LOG_REGISTER (rte_eth_dev_logtype, lib.ethdev,INFO );RTE_INIT (ethdev_init_telemetry)lib/librte_ethdev/rte_ethdev_driver.h +3
-0@@ -21,6 +21,9 @@extern "C" {#endif +/**< @internal Declaration of the hairpin peer queue information structure. */ +struct rte_hairpin_peer_info ; +/* * Definitions of all functions exported by an Ethernet driver through the * generic structure of type *eth_dev_ops* supplied in the *rte_eth_dev*
lib/librte_ethdev/rte_ethdev_driver.h +10
-0@@ -622,6 +625,21 @@ typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev, typedef int (*eth_hairpin_unbind_t)(struct rte_eth_dev *dev,uint16_t rx_port); +typedef int (*eth_hairpin_queue_peer_update_t ) + (struct rte_eth_dev *dev,uint16_t peer_queue, +struct rte_hairpin_peer_info *current_info, +struct rte_hairpin_peer_info *peer_info,bool direction); +/**< @internal Update and fetch peer queue information. */ + +typedef int (*eth_hairpin_queue_peer_bind_t ) + (struct rte_eth_dev *dev,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info,bool direction); +/**< @internal Bind peer queue to the current queue with fetched information. */
lib/librte_ethdev/rte_ethdev_driver.h +5
-0+ +typedef int (*eth_hairpin_queue_peer_unbind_t ) + (struct rte_eth_dev *dev,uint16_t cur_queue,bool direction); +/**< @internal Unbind peer queue from the current queue. */ +/** * @internal A structure containing the functions exported by an Ethernet driver.
*/lib/librte_ethdev/rte_ethdev_driver.h +6
-0@@ -765,6 +783,9 @@ struct eth_dev_ops {/**< Bind all hairpin TX queues of device to the peer port RX queues. */ eth_hairpin_unbind_t hairpin_unbind;/**< Unbind all hairpin TX queues from the peer port RX queues. */ +eth_hairpin_queue_peer_update_t hairpin_queue_peer_update; +eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind; +eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind; };/** @@ -1120,6 +1141,93 @@ __rte_internalint rte_eth_dev_destroy (struct rte_eth_dev *ethdev,ethdev_uninit_t ethdev_uninit); +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 5 lines
notice
+ *
+ * @internal
+ * Pass the current hairpin queue HW and/or HW information to the peer queue
I don't think you need experimental tag when using internal.
Quoted 29 lines
+ * and fetch back the information of the peer queue.
+ *
+ * @parampeer_port
+ * Peer port identifier of the Ethernet device.
+ * @parampeer_queue
+ * Peer queue index of the port.
+ * @paramcur_info
+ * Pointer to the current information structure.
+ * @parampeer_info
+ * Pointer to the peer information, output.
+ * @param direction+ * Direction to pass the information. + * true - pass TX queue information and get peer RX queue information + * false - pass RX queue information and get peer TX queue information+ *
+ * @return
+ * Negative errno value on error, 0 on success.
+ */lib/librte_ethdev/rte_ethdev_driver.h +3
-0+__rte_internal +int +rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t
peer_queue,lib/librte_ethdev/rte_ethdev_driver.h +7
-0+struct rte_hairpin_peer_info *cur_info, + struct rte_hairpin_peer_info *peer_info, + bool direction); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 5 lines
notice
+ *
+ * @internal
+ * Configure current hairpin queue with the peer information fetched to create
Same comment as above.
Quoted 71 lines
+ * the connection (bind) with peer queue in the specified direction.
+ * This function might need to be called twice to fully create the connection.
+ *
+ * @paramcur_port
+ * Current port identifier of the Ethernet device.
+ * @paramcur_queue
+ * Current queue index of the port.
+ * @parampeer_info
+ * Pointer to the peer information, input.
+ * @param direction+ * Direction to create the connection. + * true - bind current TX queue to peer RX queue + * false - bind current RX queue to peer TX queue+ *
+ * @return
+ * Negative errno value on error, 0 on success.
+ */lib/librte_ethdev/rte_ethdev_driver.h +9
-0+__rte_internal +int +rte_eth_hairpin_queue_peer_bind (uint16_t cur_port,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info, +bool direction); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * @internal
+ * Reset the current queue state and configuration to disconnect (unbind) it
+ * from the peer queue.
+ * This function might need to be called twice to disconnect each other.
+ *
+ * @paramcur_port
+ * Current port identifier of the Ethernet device.
+ * @paramcur_queue
+ * Current queue index of the port.
+ * @param direction+ * Direction to create the connection. + * true - unbind current TX queue from peer RX queue + * false - unbind current RX queue from peer TX queue+ *
+ * @return
+ * Negative errno value on error, 0 on success.
+ */lib/librte_ethdev/rte_ethdev_driver.h +6
-0+__rte_internal +int +rte_eth_hairpin_queue_peer_unbind (uint16_t cur_port,uint16_t cur_queue, +bool direction); + + #ifdef __cplusplus }#endif lib/librte_ethdev/rte_ethdev_version.map +3
-1@@ -250,6 +250,9 @@ INTERNAL { rte_eth_devargs_parse; rte_eth_dma_zone_free; rte_eth_dma_zone_reserve; + rte_eth_hairpin_queue_peer_bind; + rte_eth_hairpin_queue_peer_unbind; + rte_eth_hairpin_queue_peer_update; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; rte_flow_expand_rss; --2.5.5
Re: [dpdk-dev] [PATCH 3/4] ethdev: add APIs for hairpin queue operation
Hi Ori,
Quoted 205 lines
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Sunday, October 4, 2020 5:35 PM
To: Bing Zhao <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]
Subject: RE: [PATCH 3/4] ethdev: add APIs for hairpin queue operationHi Bing,
PSB
Best,
OriQuoted 9 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Subject: [PATCH 3/4] ethdev: add APIs for hairpin queue operationEvery hairpin queue pair should be configured properly and the connection between TX and RX queues should be established, before hairpin function works. In single port hairpin mode, the queues of each pair belong to the same device. It is easy to get the
hardware
Quoted 2 lines
and software information of each queue and configure the hairpin connection with such information. In two ports hairpin mode, it is
not
Quoted 1 line
easy or inappropriate to access one queue's information from
another
Quoted 6 lines
device.
Since hairpin is configured per queue pair, three new APIs are introduced and they are internal for the PMD using.
The peer update API helps to pass one queue's information to the
peer
Quoted 5 lines
queue and get the peer's information back for the next step. The peer bind API configures the current queue with the peer's information. For each hairpin queue pair, this API may need to be called twice to configure the TX, RX queues separately. The peer unbind API resets the current queue configuraion and
state to
Quoted 7 lines
disconnect it from the peer queue. Also, it may need to be called twice to disconnect TX, RX queues from each other.
Some parameter of the above APIs might not be mandatory, and it depends on the PMD implementation.
The structure of
rte_hairpin_peer_infois only a declaration andthe
Quoted 40 lines
actual members will be defined in each PMD when being used.
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 55 ++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 108 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 3 files changed, 166 insertions(+)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_ethdev.cindex 72f567b..4bfc26e 100644lib/librte_ethdev/rte_ethdev.c +18
-0@@ -5515,6 +5515,61 @@ handle_port_link_status(const char *cmd __rte_unused, return 0; } +int +rte_eth_hairpin_queue_peer_update (uint16_t peer_port,uint16_t peer_queue, +struct rte_hairpin_peer_info *cur_info, +struct rte_hairpin_peer_info *peer_info, +bool direction) +{ +struct rte_eth_dev *dev; + +/* Current queue information is not mandatory. */ +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[peer_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops- >hairpin_queue_peer_update, + -ENOTSUP ); + + return (*dev->dev_ops->hairpin_queue_peer_update)(dev,
peer_queue,lib/librte_ethdev/rte_ethdev.c handle_port_link_status(const char *cmd __rte_unused,
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+ cur_info, peer_info, direction); } + +int +rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t
cur_queue,Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +11
-0+ struct rte_hairpin_peer_info *peer_info, + bool direction) +{ +struct rte_eth_dev *dev; + +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-Quoted 1 line
hairpin_queue_peer_bind,lib/librte_ethdev/rte_ethdev.c handle_port_link_status(const char *cmd __rte_unused,
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8
-0+ -ENOTSUP); + +return (*dev->dev_ops->hairpin_queue_peer_bind)(dev, cur_queue, + peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t
cur_queue,lib/librte_ethdev/rte_ethdev.c handle_port_link_status(const char *cmd __rte_unused,
Quoted 11 lines
lib/librte_ethdev/rte_ethdev.c +7
-0+ bool direction) +{ +struct rte_eth_dev *dev; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops-Quoted 1 line
hairpin_queue_peer_bind,lib/librte_ethdev/rte_ethdev.c +3
-0+ -ENOTSUP); + + return (*dev->dev_ops->hairpin_queue_peer_unbind)(dev,
cur_queue,Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +3
-0+ direction); +} +RTE_LOG_REGISTER (rte_eth_dev_logtype, lib.ethdev,INFO );RTE_INIT (ethdev_init_telemetry)lib/librte_ethdev/rte_ethdev_driver.h +0
-0lib/librte_ethdev/rte_ethdev_driver.h line 24
Quoted 4 lines
lib/librte_ethdev/rte_ethdev_driver.h +1
-0@@ -21,6 +21,9 @@extern "C" {#endif +/**< @internal Declaration of the hairpin peer queue information structure.
lib/librte_ethdev/rte_ethdev_driver.h
Quoted 5 lines
lib/librte_ethdev/rte_ethdev_driver.h +2
-0*/ +struct rte_hairpin_peer_info ; +/* * Definitions of all functions exported by an Ethernet driver through the
lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev, · line 631
Quoted 10 lines
* generic structure of type *eth_dev_ops* supplied in the
*rte_eth_dev* @@ -622,6 +625,21 @@ typedef int (*eth_hairpin_bind_t)(structrte_eth_dev*dev, typedef int (*eth_hairpin_unbind_t)(structrte_eth_dev*dev,lib/librte_ethdev/rte_ethdev_driver.h +4
-0uint16_t rx_port); +typedef int (*eth_hairpin_queue_peer_update_t ) + (struct rte_eth_dev *dev,uint16_t peer_queue, +struct rte_hairpin_peer_info *current_info, +struct rte_hairpin_peer_info *peer_info,bool direction);/**<
lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev, · line 636
Quoted 5 lines
+@internal Update and fetch peer queue information. */
lib/librte_ethdev/rte_ethdev_driver.h +4
-0+ +typedef int (*eth_hairpin_queue_peer_bind_t ) + (struct rte_eth_dev *dev,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info,bool direction);/**<
lib/librte_ethdev/rte_ethdev_driver.h typedef int (*eth_hairpin_bind_t)(struct rte_eth_dev *dev, · line 640
Quoted 5 lines
+@internal Bind peer queue to the current queue with fetched information. */
lib/librte_ethdev/rte_ethdev_driver.h +3
-0+ +typedef int (*eth_hairpin_queue_peer_unbind_t ) + (struct rte_eth_dev *dev,uint16_t cur_queue,bool direction);/**<
lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 783
Quoted 8 lines
+@internal Unbind peer queue from the current queue. */ +
/**
* @internal A structure containing the functions exported by an
Ethernet driver.
*/lib/librte_ethdev/rte_ethdev_driver.h +0
-0@@ -765,6 +783,9 @@ struct eth_dev_ops {/**< Bind all hairpin TX queues of device to the peer port RX queues. */
lib/librte_ethdev/rte_ethdev_driver.h struct eth_dev_ops { · line 785
Quoted 2 lines
lib/librte_ethdev/rte_ethdev_driver.h +0
-0eth_hairpin_unbind_t hairpin_unbind;/**< Unbind all hairpin TX queues from the peer port RX queues. */
Quoted 7 lines
lib/librte_ethdev/rte_ethdev_driver.h +3
-0+eth_hairpin_queue_peer_update_t hairpin_queue_peer_update; +eth_hairpin_queue_peer_bind_t hairpin_queue_peer_bind; +eth_hairpin_queue_peer_unbind_t hairpin_queue_peer_unbind; };/** lib/librte_ethdev/rte_ethdev_driver.h __rte_internal · line 1147
Quoted 7 lines
lib/librte_ethdev/rte_ethdev_driver.h +3
-0@@ -1120,6 +1141,93 @@ __rte_internalint rte_eth_dev_destroy (struct rte_eth_dev *ethdev,ethdev_uninit_t ethdev_uninit); +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 8 lines
Quoted 6 lines
notice
+ *
+ * @internal
+ * Pass the current hairpin queue HW and/or HW information to the
+ peer
queueI don't think you need experimental tag when using internal.
OK, I will remove it.
Quoted 37 lines
Quoted 25 lines
+ * and fetch back the information of the peer queue.
+ *
+ * @parampeer_port
+ * Peer port identifier of the Ethernet device.
+ * @parampeer_queue
+ * Peer queue index of the port.
+ * @paramcur_info
+ * Pointer to the current information structure.
+ * @parampeer_info
+ * Pointer to the peer information, output.
+ * @param direction
+ * Direction to pass the information.
+ * true - pass TX queue information and get peer RX queuelib/librte_ethdev/rte_ethdev_driver.h +10
-0+information +* false - pass RX queue information and get peer TX queue +information +* +* @return +* Negative errno value on error, 0 on success. +*/ +__rte_internal +int +rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t
peer_queue,lib/librte_ethdev/rte_ethdev_driver.h __rte_internal
Quoted 7 lines
lib/librte_ethdev/rte_ethdev_driver.h +7
-0+struct rte_hairpin_peer_info *cur_info, + struct rte_hairpin_peer_info *peer_info, + bool direction); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 4 lines
notice
+ *
+ * @internal
+ * Configure current hairpin queue with the peer information
Quoted 5 lines
fetched
Quoted 2 lines
+ to
createSame comment as above.
I will remove it.
Quoted 71 lines
Quoted 2 lines
+ * the connection (bind) with peer queue in the specified
direction.
Quoted 1 line
+ * This function might need to be called twice to fully create
the connection.
Quoted 15 lines
+ *
+ * @paramcur_port
+ * Current port identifier of the Ethernet device.
+ * @paramcur_queue
+ * Current queue index of the port.
+ * @parampeer_info
+ * Pointer to the peer information, input.
+ * @param direction+ * Direction to create the connection. + * true - bind current TX queue to peer RX queue + * false - bind current RX queue to peer TX queue+ *
+ * @return
+ * Negative errno value on error, 0 on success.
+ */lib/librte_ethdev/rte_ethdev_driver.h __rte_internal
Quoted 3 lines
lib/librte_ethdev/rte_ethdev_driver.h +3
-0+__rte_internal +int +rte_eth_hairpin_queue_peer_bind(uint16_t cur_port, uint16_t
cur_queue,lib/librte_ethdev/rte_ethdev_driver.h __rte_internal
Quoted 6 lines
lib/librte_ethdev/rte_ethdev_driver.h +6
-0+struct rte_hairpin_peer_info *peer_info, + bool direction); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 7 lines
notice
+ *
+ * @internal
+ * Reset the current queue state and configuration to disconnect +(unbind) it
+ * from the peer queue.
+ * This function might need to be called twice to disconnect eachother.
Quoted 13 lines
+ *
+ * @paramcur_port
+ * Current port identifier of the Ethernet device.
+ * @paramcur_queue
+ * Current queue index of the port.
+ * @param direction+ * Direction to create the connection. + * true - unbind current TX queue from peer RX queue + * false - unbind current RX queue from peer TX queue+ *
+ * @return
+ * Negative errno value on error, 0 on success.
+ */lib/librte_ethdev/rte_ethdev_driver.h __rte_internal
Quoted 3 lines
lib/librte_ethdev/rte_ethdev_driver.h +3
-0+__rte_internal +int +rte_eth_hairpin_queue_peer_unbind(uint16_t cur_port, uint16_t
cur_queue,Quoted 15 lines
lib/librte_ethdev/rte_ethdev_driver.h +3
-0+ bool direction); + + #ifdef __cplusplus }#endif lib/librte_ethdev/rte_ethdev_version.map +0
-0@@ -250,6 +250,9 @@ INTERNAL { rte_eth_devargs_parse; rte_eth_dma_zone_free; rte_eth_dma_zone_reserve;
Quoted 8 lines
Quoted 8 lines
lib/librte_ethdev/rte_ethdev_version.map +3
-1+ rte_eth_hairpin_queue_peer_bind; + rte_eth_hairpin_queue_peer_unbind; + rte_eth_hairpin_queue_peer_update; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; rte_flow_expand_rss; --2.5.5
Thanks
PATCH v2 4/4 app/testpmd: change hairpin queues setup
In reply to Bing ZhaoA new parameter hairpin-mode is introduced to the testpmd command line. Bitmask value is used to provide more flexible configuration.
Bit 0 in the LSB indicates the hairpin will use the loop mode. The previous port RX queue will be connected to the current port TX queue.
Bit 1 in the LSB indicates the hairpin will use pair port mode. The even index port will be paired with the next odd index port. If the total number of probed port is odd, then the last one will be paired to itself.
If this byte is zero, then each port will be paired to itself. Bit 0 takes a higher priority in the checking.
Bit 4 in the second bytes indicate if the hairpin will use explicit TX flow mode.
If not set, default value zero will be used and the behavior will try to get align with the previous single port mode. If the ports belong to different vendors' NICs, it is suggested to use the self hairpin mode only.
Since hairpin configures the hardware resources, the port mask of packets forwarding engine will not be used here.
--- app/test-pmd/parameters.c | 15 +++++++++++ app/test-pmd/testpmd.c | 68 ++++++++++++++++++++++++++++++++++++++++++++--- app/test-pmd/testpmd.h | 2 ++ 3 files changed, 81 insertions(+), 4 deletions(-)
app/test-pmd/parameters.c +15 -0
@@ -221,6 +221,9 @@ usage(char* progname) "enabled\n");printf (" --record-core-cycles: enable measurement of CPU cycles.\n" );printf (" --record-burst-stats: enable display of RX and TX bursts.\n" ); +printf (" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n " +" 0x10 - explicit tx rule, 0x02 - hairpin ports paired\n" +" 0x01 - hairpin ports loop, 0x00 - hairpin port self\n" ); }#ifdef RTE_LIBRTE_CMDLINE
@@ -644,6 +647,7 @@ launch_args_parse(int argc, char** argv) { "rxd", 1, 0, 0 }, { "txd", 1, 0, 0 }, { "hairpinq", 1, 0, 0 }, + { "hairpin-mode", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 },
@@ -1111,6 +1115,17 @@ launch_args_parse(int argc, char** argv)rte_exit (EXIT_FAILURE ,"Either rx or tx queues should " "be non-zero\n" ); } +if (!strcmp (lgopts[opt_idx].name,"hairpin-mode" )) { +char *end =NULL ; +unsigned int n; + + errno =0 ; + n =strtoul (optarg, &end,0 ); +if (errno !=0 || end == optarg) +rte_exit (EXIT_FAILURE ,"hairpin mode invalid\n" ); +else + hairpin_mode = (uint16_t )n; + }if (!strcmp (lgopts[opt_idx].name,"burst" )) { n =atoi (optarg);if (n ==0 ) {
app/test-pmd/testpmd.c +64 -4
115 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -398,6 +398,8 @@ extern uint32_t param_total_num_mbufs;extern uint16_t stats_period; +extern uint16_t hairpin_mode; +#ifdef RTE_LIBRTE_LATENCY_STATS extern uint8_t latencystats_enabled;extern lcoreid_t latencystats_lcore_id;
Signature · 1 line
2.5.5
Re: [dpdk-dev] [PATCH 4/4] app/testpmd: change hairpin queues setup
Hi Bing,
PSB,
Best,
Ori
Quoted 18 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Subject: [PATCH 4/4] app/testpmd: change hairpin queues setupA new parameter
hairpin-modeis introduced to the testpmd command line. Bitmask value is used to provide more flexible configuration.Bit 0 in the LSB indicates the hairpin will use the loop mode. The previous port RX queue will be connected to the current port TX queue.
Bit 1 in the LSB indicates the hairpin will use pair port mode. The even index port will be paired with the next odd index port. If the total number of probed port is odd, then the last one will be paired to itself.
If this byte is zero, then each port will be paired to itself. Bit 0 takes a higher priority in the checking.
Quoted 3 lines
Bit 4 in the second bytes indicate if the hairpin will use explicit TX flow mode.
I think some basic example will be great here.
Quoted 201 lines
If not set, default value zero will be used and the behavior will try to get align with the previous single port mode. If the ports belong to different vendors' NICs, it is suggested to use the
selfhairpin mode only.Since hairpin configures the hardware resources, the port mask of packets forwarding engine will not be used here.
Signed-off-by Bing Zhao <[email protected]>--- app/test-pmd/parameters.c | 15 +++++++++++ app/test-pmd/testpmd.c | 68 ++++++++++++++++++++++++++++++++++++++++++++--- app/test-pmd/testpmd.h | 2 ++ 3 files changed, 81 insertions(+), 4 deletions(-)app/test-pmd/parameters.c +4
-0@@ -221,6 +221,9 @@ usage(char* progname) "enabled\n");printf (" --record-core-cycles: enable measurement of CPU cycles.\n" );printf (" --record-burst-stats: enable display of RX and TX bursts.\n" ); +printf (" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n " +" 0x10 - explicit tx rule, 0x02 - hairpin ports paired\n" +" 0x01 - hairpin ports loop, 0x00 - hairpin port self\n" ); }#ifdef RTE_LIBRTE_CMDLINE @@ -644,6 +647,7 @@ launch_args_parse(int argc, char** argv) { "rxd", 1, 0, 0 }, { "txd", 1, 0, 0 }, { "hairpinq", 1, 0, 0 }, + { "hairpin-mode", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 },@@ -1111,6 +1115,17 @@ launch_args_parse(int argc, char** argv) rte_exit(EXIT_FAILURE, "Either rx or tx queuesshould "
app/test-pmd/parameters.c +8
-0"be non-zero\n"); } +if (!strcmp (lgopts[opt_idx].name,"hairpin-mode" )) { +char *end =NULL ; +unsigned int n; + + errno =0 ; + n =strtoul (optarg, &end,0 ); +if (errno !=0 || end == optarg) + rte_exit(EXIT_FAILURE, "hairpin modeinvalid\n");
app/test-pmd/parameters.c +3
-0+else + hairpin_mode = (uint16_t )n; + }if (!strcmp (lgopts[opt_idx].name,"burst" )) { n =atoi (optarg);if (n ==0 ) {app/test-pmd/testpmd.c +43
-2@@ -367,6 +367,9 @@ bool setup_on_probe_event = true;/* Clear ptypes on port initialization. */ uint8_t clear_ptypes = true; +/* Hairpin ports configuration mode. */ +uint16_t hairpin_mode; +/* Pretty printing of ethdev events */ static const char *const eth_event_desc[] = { [RTE_ETH_EVENT_UNKNOWN ] ="unknown" ,@@ -2345,7 +2348,7 @@ port_is_started(portid_t port_id)/* Configure the Rx and Tx hairpin queues for the selected port. */ static int -setup_hairpin_queues (portid_t pi) +setup_hairpin_queues (portid_t pi,portid_t p_pi,uint16_t cnt_pi) {queueid_t qi;struct rte_eth_hairpin_conf hairpin_conf = {@@ -2354,10 +2357,48 @@ setup_hairpin_queues(portid_t pi)int i;int diag;struct rte_port *port = &ports[pi]; +uint16_t peer_rx_port = pi; +uint16_t peer_tx_port = pi; +uint32_t manual =1 ; +uint32_t tx_exp = hairpin_mode &0x10 ; + +if (!(hairpin_mode &0xf )) { + peer_rx_port = pi; + peer_tx_port = pi; + manual =0 ; + }else if (hairpin_mode &0x1 ) { + peer_tx_port =rte_eth_find_next_owned_by (pi +1 , +RTE_ETH_DEV_NO_OWNER ); +if (peer_tx_port >=RTE_MAX_ETHPORTS ) + peer_tx_port =rte_eth_find_next_owned_by (0 , +RTE_ETH_DEV_NO_OWNER ); +if (p_pi !=RTE_MAX_ETHPORTS ) { + peer_rx_port = p_pi; + }else { +uint16_t next_pi; + +RTE_ETH_FOREACH_DEV (next_pi) + peer_rx_port = next_pi; + } + manual =1 ; + }else if (hairpin_mode &0x2 ) { +if (cnt_pi &0x1 ) { + peer_rx_port = p_pi; + }else { + peer_rx_port =rte_eth_find_next_owned_by (pi +1 , +RTE_ETH_DEV_NO_OWNER ); +if (peer_rx_port >=RTE_MAX_ETHPORTS ) + peer_rx_port = pi; + } + peer_tx_port = peer_rx_port; + manual =1 ; + }for (qi = nb_txq, i =0 ; qi < nb_hairpinq + nb_txq; qi++) { - hairpin_conf.peers[0 ].port = pi; + hairpin_conf.peers[0 ].port = peer_rx_port; hairpin_conf.peers[0 ].queue = i + nb_rxq; + hairpin_conf.manual_bind = !!manual; + hairpin_conf.tx_explicit = !!tx_exp; diag =rte_eth_tx_hairpin_queue_setup (pi, qi, nb_txd, &hairpin_conf);app/test-pmd/testpmd.c +21
-2i++;@@ -2377,8 +2418,10 @@ setup_hairpin_queues(portid_t pi)return -1 ; }for (qi = nb_rxq, i =0 ; qi < nb_hairpinq + nb_rxq; qi++) { - hairpin_conf.peers[0 ].port = pi; + hairpin_conf.peers[0 ].port = peer_tx_port; hairpin_conf.peers[0 ].queue = i + nb_txq; + hairpin_conf.manual_bind = !!manual; + hairpin_conf.tx_explicit = !!tx_exp; diag =rte_eth_rx_hairpin_queue_setup (pi, qi, nb_rxd, &hairpin_conf); i++;@@ -2405,6 +2448,8 @@ start_port(portid_t pid) {int diag, need_check_link_status =-1 ;portid_t pi; +portid_t p_pi =RTE_MAX_ETHPORTS ; +uint16_t cnt_pi =0 ;queueid_t qi;struct rte_port *port;struct rte_ether_addr mac_addr;@@ -2544,8 +2589,10 @@ start_port(portid_t pid)return -1 ; }/* setup hairpin queues */ -if (setup_hairpin_queues (pi) !=0 ) +if (setup_hairpin_queues (pi, p_pi, cnt_pi) !=0 )return -1 ; + p_pi = pi; + cnt_pi++; }configure_rxtx_dump_callbacks (verbose_level);if (clear_ptypes) {@@ -3775,6 +3822,19 @@ main(int argc, char** argv)rte_exit (EXIT_FAILURE ,"Start ports failed\n" );/* set all ports to promiscuous mode by default */ +if (hairpin_mode &0x3 ) { +RTE_ETH_FOREACH_DEV (port_id) { + ret =rte_eth_hairpin_bind (port_id,RTE_MAX_ETHPORTS ); +if (ret !=0 ) { +RTE_LOG (ERR ,EAL ,"Error during binding " +"hairpin tx port %u: %s" , + port_id,rte_strerror (-ret)); +return -1 ; + } + } + } + +/* set all ports to promiscuous mode by default */ RTE_ETH_FOREACH_DEV (port_id) { ret =rte_eth_promiscuous_enable (port_id);app/test-pmd/testpmd.c +0
-0if (ret !=0 )app/test-pmd/testpmd.h +2
-1@@ -398,6 +398,8 @@ extern uint32_t param_total_num_mbufs;extern uint16_t stats_period; +extern uint16_t hairpin_mode; +#ifdef RTE_LIBRTE_LATENCY_STATS extern uint8_t latencystats_enabled;extern lcoreid_t latencystats_lcore_id; --2.5.5
Re: [dpdk-dev] [PATCH 4/4] app/testpmd: change hairpin queues setup
Hi Ori,
Thanks for your comments.
I will update the commit logs as well as the documents.
BR. Bing
Quoted 256 lines
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Sunday, October 4, 2020 5:40 PM
To: Bing Zhao <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]
Subject: RE: [PATCH 4/4] app/testpmd: change hairpin queues setupHi Bing,
PSB,
Best,
OriQuoted 6 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Subject: [PATCH 4/4] app/testpmd: change hairpin queues setupA new parameter
hairpin-modeis introduced to the testpmdcommand
Quoted 4 lines
line. Bitmask value is used to provide more flexible configuration.
Bit 0 in the LSB indicates the hairpin will use the loop mode. The previous port RX queue will be connected to the current port TX
queue.
Quoted 1 line
Bit 1 in the LSB indicates the hairpin will use pair port mode.
The
Quoted 1 line
even index port will be paired with the next odd index port. If
the
Quoted 1 line
total number of probed port is odd, then the last one will be
paired
Quoted 5 lines
to itself.
If this byte is zero, then each port will be paired to itself. Bit 0 takes a higher priority in the checking.Bit 4 in the second bytes indicate if the hairpin will use
explicit TX
Quoted 2 lines
flow mode.
I think some basic example will be great here.
Quoted 1 line
If not set, default value zero will be used and the behavior will
try
Quoted 1 line
to get align with the previous single port mode. If the ports
belong
Quoted 1 line
to different vendors' NICs, it is suggested to use the
selfhairpin
Quoted 18 lines
mode only.
Since hairpin configures the hardware resources, the port mask of packets forwarding engine will not be used here.
Signed-off-by Bing Zhao <[email protected]>--- app/test-pmd/parameters.c | 15 +++++++++++ app/test-pmd/testpmd.c | 68 ++++++++++++++++++++++++++++++++++++++++++++--- app/test-pmd/testpmd.h | 2 ++ 3 files changed, 81 insertions(+), 4 deletions(-)app/test-pmd/parameters.c +0
-0app/test-pmd/parameters.c usage(char* progname) · line 222
Quoted 2 lines
app/test-pmd/parameters.c +0
-0@@ -221,6 +221,9 @@ usage(char* progname) "enabled\n"); printf(" --record-core-cycles: enable measurement of CPUcycles.\n");
app/test-pmd/parameters.c usage(char* progname) · line 225
Quoted 3 lines
app/test-pmd/parameters.c +1
-0printf(" --record-burst-stats: enable display of RX and TX bursts.\n"); + printf(" --hairpin-mode=0xXX: bitmask set the hairpin portmode.\n "
app/test-pmd/parameters.c usage(char* progname) · line 226
Quoted 1 line
app/test-pmd/parameters.c +1
-0+ " 0x10 - explicit tx rule, 0x02 - hairpin portspaired\n"
app/test-pmd/parameters.c usage(char* progname) · line 227
Quoted 1 line
app/test-pmd/parameters.c +1
-0+ " 0x01 - hairpin ports loop, 0x00 - hairpin portself\n");
app/test-pmd/parameters.c launch_args_parse(int argc, char** argv) · line 1115
Quoted 13 lines
app/test-pmd/parameters.c +0
-0}#ifdef
RTE_LIBRTE_CMDLINEapp/test-pmd/parameters.c +1
-0@@ -644,6 +647,7 @@ launch_args_parse(int argc, char** argv) { "rxd", 1, 0, 0 }, { "txd", 1, 0, 0 }, { "hairpinq", 1, 0, 0 }, + { "hairpin-mode", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 },@@ -1111,6 +1115,17 @@ launch_args_parse(int argc, char** argv) rte_exit(EXIT_FAILURE, "Either rx or txqueues should "
app/test-pmd/parameters.c launch_args_parse(int argc, char** argv)
Quoted 3 lines
app/test-pmd/parameters.c +1
-0"be non-zero\n"); } +if (!strcmp (lgopts[opt_idx].name,"hairpin-mode" )){
Quoted 19 lines
app/test-pmd/parameters.c +10
-0+char *end =NULL ; +unsigned int n; + + errno =0 ; + n =strtoul (optarg, &end,0 ); +if (errno !=0 || end == optarg) +rte_exit (EXIT_FAILURE ,"hairpin mode invalid\n"); +else + hairpin_mode = (uint16_t )n; + }if (!strcmp (lgopts[opt_idx].name,"burst" )) { n =atoi (optarg);app/test-pmd/parameters.c +0
-0if (n ==0 ) {app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-0fe6450c..c604045 100644
app/test-pmd/testpmd.c bool setup_on_probe_event = true; · line 367
Quoted 1 line
app/test-pmd/testpmd.c +0
-0@@ -367,6 +367,9 @@ bool setup_on_probe_event = true;/* Clear ptypes on port initialization. */ uint8_t clear_ptypes=
Quoted 10 lines
app/test-pmd/testpmd.c +2
-0true; +/* Hairpin ports configuration mode. */ uint16_t hairpin_mode; +/* Pretty printing of ethdev events */ static const char *const eth_event_desc[] = { [RTE_ETH_EVENT_UNKNOWN] = "unknown", @@ -2345,7 +2348,7 @@
port_is_started(portid_t port_id)/* Configure the Rx and Tx hairpin queues for the selected port.
*/
app/test-pmd/testpmd.c port_is_started(portid_t port_id)
Quoted 5 lines
static int -setup_hairpin_queues(portid_t pi)
app/test-pmd/testpmd.c +1
-0+setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) { queueid_t qi; struct rte_eth_hairpin_conf hairpin_conf = { @@ -2354,10+2357,48 @@
Quoted 119 lines
setup_hairpin_queues(portid_t pi)app/test-pmd/testpmd.c +12
-0int i;int diag;struct rte_port *port = &ports[pi]; +uint16_t peer_rx_port = pi; +uint16_t peer_tx_port = pi; +uint32_t manual =1 ; +uint32_t tx_exp = hairpin_mode &0x10 ; + +if (!(hairpin_mode &0xf )) { + peer_rx_port = pi; + peer_tx_port = pi; + manual =0 ; + }else if (hairpin_mode &0x1 ) { + peer_tx_port = rte_eth_find_next_owned_by(pi + 1, +
RTE_ETH_DEV_NO_OWNER);app/test-pmd/testpmd.c +48
-3+if (peer_tx_port >=RTE_MAX_ETHPORTS ) + peer_tx_port =rte_eth_find_next_owned_by (0 , +RTE_ETH_DEV_NO_OWNER ); +if (p_pi !=RTE_MAX_ETHPORTS ) { + peer_rx_port = p_pi; + }else { +uint16_t next_pi; + +RTE_ETH_FOREACH_DEV (next_pi) + peer_rx_port = next_pi; + } + manual =1 ; + }else if (hairpin_mode &0x2 ) { +if (cnt_pi &0x1 ) { + peer_rx_port = p_pi; + }else { + peer_rx_port =rte_eth_find_next_owned_by (pi +1 , +RTE_ETH_DEV_NO_OWNER ); +if (peer_rx_port >=RTE_MAX_ETHPORTS ) + peer_rx_port = pi; + } + peer_tx_port = peer_rx_port; + manual =1 ; + }for (qi = nb_txq, i =0 ; qi < nb_hairpinq + nb_txq; qi++) { - hairpin_conf.peers[0 ].port = pi; + hairpin_conf.peers[0 ].port = peer_rx_port; hairpin_conf.peers[0 ].queue = i + nb_rxq; + hairpin_conf.manual_bind = !!manual; + hairpin_conf.tx_explicit = !!tx_exp; diag =rte_eth_tx_hairpin_queue_setup (pi, qi, nb_txd, &hairpin_conf); i++;@@ -2377,8 +2418,10 @@ setup_hairpin_queues(portid_t pi)return -1 ; }for (qi = nb_rxq, i =0 ; qi < nb_hairpinq + nb_rxq; qi++) { - hairpin_conf.peers[0 ].port = pi; + hairpin_conf.peers[0 ].port = peer_tx_port; hairpin_conf.peers[0 ].queue = i + nb_txq; + hairpin_conf.manual_bind = !!manual; + hairpin_conf.tx_explicit = !!tx_exp; diag =rte_eth_rx_hairpin_queue_setup (pi, qi, nb_rxd, &hairpin_conf); i++;@@ -2405,6 +2448,8 @@ start_port(portid_t pid) {int diag, need_check_link_status =-1 ;portid_t pi; +portid_t p_pi =RTE_MAX_ETHPORTS ; +uint16_t cnt_pi =0 ;queueid_t qi;struct rte_port *port;struct rte_ether_addr mac_addr;@@ -2544,8 +2589,10 @@ start_port(portid_t pid)return -1 ; }/* setup hairpin queues */ -if (setup_hairpin_queues (pi) !=0 ) +if (setup_hairpin_queues (pi, p_pi, cnt_pi) !=0 )return -1 ; + p_pi = pi; + cnt_pi++; }configure_rxtx_dump_callbacks (verbose_level);if (clear_ptypes) {@@ -3775,6 +3822,19 @@ main(int argc, char** argv)rte_exit (EXIT_FAILURE ,"Start ports failed\n" );/* set all ports to promiscuous mode by default */ +if (hairpin_mode &0x3 ) { +RTE_ETH_FOREACH_DEV (port_id) { + ret =rte_eth_hairpin_bind (port_id,RTE_MAX_ETHPORTS ); +if (ret !=0 ) { +RTE_LOG (ERR ,EAL ,"Error during binding " +"hairpin tx port %u: %s" , + port_id,rte_strerror (-ret)); +return -1 ; + } + } + } + +/* set all ports to promiscuous mode by default */ RTE_ETH_FOREACH_DEV (port_id) { ret =rte_eth_promiscuous_enable (port_id);app/test-pmd/testpmd.c +0
-0if (ret !=0 )app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0
-0c7e7e41..29ede20 100644
app/test-pmd/testpmd.h +2
-1@@ -398,6 +398,8 @@ extern uint32_t param_total_num_mbufs;extern uint16_t stats_period; +extern uint16_t hairpin_mode; +#ifdef RTE_LIBRTE_LATENCY_STATS extern uint8_t latencystats_enabled;extern lcoreid_t latencystats_lcore_id; --2.5.5
Hi Bing
General comment I think in all of this patch set you are missing the documentation part., for example the testpmd doc.
Thanks,
Ori
Quoted 37 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 1, 2020 3:26 AM
Subject: [PATCH 0/4] introduce support for hairpin between two portsThis patch set will add the support for hairpin between two ports. In the meanwhile, the compatibility of the previous single port mode is taken into consideration and kept.
The patches contain the following changes:
1. new APIs to bind and unbind hairpin ports in manual binding mode.
2. new internal APIs for PMD to pass the queue information and configure the queue pair.
3. new attribute members in the hairpin queue configuraiton structure to specify the binding mode and enable explicit TX flow mode.
4. Testpmd support to configure the hairpin modes for two ports hairpin verification.Bing Zhao (4):
ethdev: add hairpin bind and unbind APIs
ethdev: add new attributes to hairpin config
ethdev: add APIs for hairpin queue operation
app/testpmd: change hairpin queues setupapp/test-pmd/parameters.c | 15 +++ app/test-pmd/testpmd.c | 68 ++++++++++++- app/test-pmd/testpmd.h | 2 + lib/librte_ethdev/rte_ethdev.c | 162 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 69 +++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 160 ++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 5 + 7 files changed, 477 insertions(+), 4 deletions(-)--
2.5.5
v2 cover introduce support for hairpin between two ports
In reply to Bing ZhaoThe patches contain the following changes:
1. new APIs to bind and unbind hairpin ports in manual binding mode.
2. new API to get the hairpin peer ports list.
3. new internal APIs for PMD to pass the queue information and configure the queue pair.
4. new attribute members in the hairpin queue configuraiton structure to specify the binding mode and enable explicit TX flow mode.
5. Testpmd support to configure the hairpin modes for two ports hairpin verification.
6. documents update.
---
v2:
1. add documents update
2. remove all peer ports logic from rte API
3. conf structure optimizing
4. new API to get the peer ports and testpmd change to support hot-plug / unplug case
---
Bing Zhao (6):
ethdev: add hairpin bind and unbind APIs
ethdev: add new attributes to hairpin config
ethdev: add API to get hairpin peer ports list
ethdev: add APIs for hairpin queue operation
app/testpmd: change hairpin queues setup
doc: update for two ports hairpin mode
app/test-pmd/parameters.c | 15 +++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++- app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 3 + doc/guides/rel_notes/release_20_11.rst | 8 ++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++ lib/librte_ethdev/rte_ethdev.c | 133 +++++++++++++++++++++- lib/librte_ethdev/rte_ethdev.h | 83 +++++++++++++- lib/librte_ethdev/rte_ethdev_driver.h | 184 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 6 + 10 files changed, 558 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/6 ethdev: add hairpin bind and unbind APIs
In single port hairpin mode, all the hairpin TX and RX queues belong to the same device. After the queues are set up properly, there is no other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized already for the binding process.
But in two ports hairpin mode, there will be some cross-dependences between two different ports. Usually, the ports will be initialized serially by the main thread but not in parallel. The earlier port will not be able to enable the bind if the following peer port is not yet configured with HW resources. What's more, if one port is detached / attached dynamically, it would introduce more trouble for the hairpin binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set up. Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the rte_eth_hairpin_bind() API can be called to bind the all TX queues of the egress port to the RX queues of the peer port. Then the connection between the egress and ingress ports pair will be established.
The rte_eth_hairpin_unbind() API could be used to disconnect the egress and the peer ingress ports. This should only be called before the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken into consideration, especially in the hot unplug case.
---
v2: remove the all peer ports logic from rte API
--- lib/librte_ethdev/rte_ethdev.c | 46 ++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 51 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 ++ 4 files changed, 151 insertions(+)
lib/librte_ethdev/rte_ethdev.c +46 -0
@@ -2162,6 +2162,52 @@ struct rte_eth_dev *return eth_err (port_id, ret); } +int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +int ret; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is not started" , tx_port); +return -EBUSY ; + } + +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_bind, -ENOTSUP ); + ret = (*dev->dev_ops->hairpin_bind)(dev, rx_port); +if (ret) +RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX %d " +"to RX %d (%d - all ports)" , tx_port, + rx_port,RTE_MAX_ETHPORTS ); + +return ret; +} + +int +rte_eth_hairpin_unbind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +int ret; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is already stopped" , tx_port); +return -EBUSY ; + } + +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_unbind, -ENOTSUP ); + ret = (*dev->dev_ops->hairpin_unbind)(dev, rx_port); +if (ret) +RTE_ETHDEV_LOG (ERR ,"Failed to unbind hairpin " +"TX %d from RX %d (%d - all ports)" , tx_port, + rx_port,RTE_MAX_ETHPORTS ); + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)
lib/librte_ethdev/rte_ethdev.h +51 -0
57 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_driver.h +52 -0
64 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +2 -0
@@ -227,6 +227,8 @@ EXPERIMENTAL { rte_tm_wred_profile_delete; # added in 20.11 + rte_eth_hairpin_bind; + rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; };
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 1/6] ethdev: add hairpin bind and unbind APIs
Hi Bing
Quoted 36 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 8, 2020 11:52 AM
Subject: [PATCH v2 1/6] ethdev: add hairpin bind and unbind APIsIn single port hairpin mode, all the hairpin TX and RX queues belong to the same device. After the queues are set up properly, there is no other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized already for the binding process.
But in two ports hairpin mode, there will be some cross-dependences between two different ports. Usually, the ports will be initialized serially by the main thread but not in parallel. The earlier port will not be able to enable the bind if the following peer port is not yet configured with HW resources. What's more, if one port is detached / attached dynamically, it would introduce more trouble for the hairpin binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set up. Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the
rte_eth_hairpin_bind()API can be called to bind the all TX queues of the egress port to the RX queues of the peer port. Then the connection between the egress and ingress ports pair will be established.The
rte_eth_hairpin_unbind()API could be used to disconnect the egress and the peer ingress ports. This should only be called before the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken into consideration, especially in the hot unplug case.
Quoted 4 lines
Signed-off-by Bing Zhao <[email protected]>---
v2: remove the all peer ports logic from rte API
---
Thanks,
Ori
PATCH v2 2/6 ethdev: add new attributes to hairpin config
In reply to Bing ZhaoTo support two ports hairpin mode and keep the backward compatibility for the application, two new attribute members of hairpin queue configuration structure are added.
tx_explicit means if the application itself will insert the TX part flow rules. If not set, PMD will insert the rules implicitly. manual_bind means if the hairpin TX queue and peer RX queue will be bound automatically during device start stage.
Different TX and RX queue pairs could have different values, but it is highly recommended that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD drivers.
In a single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means no bind API needs to be called and no TX flow rules need to be inserted manually by the application.
---
v2: optimize the structure and remove unused macros
--- lib/librte_ethdev/rte_ethdev.c | 8 ++++---- lib/librte_ethdev/rte_ethdev.h | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-)
lib/librte_ethdev/rte_ethdev.c +4 -4
@@ -1954,13 +1954,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_rx_2_tx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Rx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_rx_2_tx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Rx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
@@ -2125,13 +2125,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_tx_2_rx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Tx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_tx_2_rx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Tx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
lib/librte_ethdev/rte_ethdev.h +4 -1
@@ -1045,7 +1045,10 @@ struct rte_eth_hairpin_peer {* A structure used to configure hairpin binding. */ struct rte_eth_hairpin_conf { -uint16_t peer_count;/**< The number of peers. */ +uint32_t peer_count:16 ;/**< The number of peers. */ +uint32_t tx_explicit:1 ;/**< Explicit TX flow rule mode. */ +uint32_t manual_bind:1 ;/**< Manually bind hairpin queues. */ +uint32_t reserved:14 ;/**< Reserved bits. */ struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; };
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 2/6] ethdev: add new attributes to hairpin config
Hi Bing,
Quoted 94 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 8, 2020 11:52 AM
Subject: [PATCH v2 2/6] ethdev: add new attributes to hairpin configTo support two ports hairpin mode and keep the backward compatibility for the application, two new attribute members of hairpin queue configuration structure are added.
tx_explicitmeans if the application itself will insert the TX part flow rules. If not set, PMD will insert the rules implicitly.manual_bindmeans if the hairpin TX queue and peer RX queue will be bound automatically during device start stage.Different TX and RX queue pairs could have different values, but it is highly recommended that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD drivers.
In a single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means no bind API needs to be called and no TX flow rules need to be inserted manually by the application.
Signed-off-by Bing Zhao <[email protected]>---
v2: optimize the structure and remove unused macros--- lib/librte_ethdev/rte_ethdev.c | 8 ++++---- lib/librte_ethdev/rte_ethdev.h | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-)lib/librte_ethdev/rte_ethdev.c +2
-2@@ -1954,13 +1954,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_rx_2_tx) {RTE_ETHDEV_LOG (ERR , - "Invalid value for number of peers for Rx queue(=%hu), should be: <= %hu", + "Invalid value for number of peers for Rx queue(=%u), should be: <= %hu", conf->peer_count, cap.max_rx_2_tx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , - "Invalid value for number of peers for Rx queue(=%hu), should be: > 0", + "Invalid value for number of peers for Rx queue(=%u),should be: > 0",
lib/librte_ethdev/rte_ethdev.c +2
-2conf->peer_count);return -EINVAL ; }@@ -2125,13 +2125,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_tx_2_rx) {RTE_ETHDEV_LOG (ERR , - "Invalid value for number of peers for Tx queue(=%hu), should be: <= %hu", + "Invalid value for number of peers for Tx queue(=%u), should be: <= %hu", conf->peer_count, cap.max_tx_2_rx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , - "Invalid value for number of peers for Tx queue(=%hu), should be: > 0", + "Invalid value for number of peers for Tx queue(=%u),should be: > 0",
lib/librte_ethdev/rte_ethdev.c +0
-0conf->peer_count);return -EINVAL ; }lib/librte_ethdev/rte_ethdev.h +4
-2@@ -1045,7 +1045,10 @@ struct rte_eth_hairpin_peer {* A structure used to configure hairpin binding. */ struct rte_eth_hairpin_conf { -uint16_t peer_count;/**< The number of peers. */ +uint32_t peer_count:16 ;/**< The number of peers. */ +uint32_t tx_explicit:1 ;/**< Explicit TX flow rule mode. */ +uint32_t manual_bind:1 ;/**< Manually bind hairpin queues. */ +uint32_t reserved:14 ;/**< Reserved bits. */ struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; }; --
Quoted 1 line
1.8.3.1
Thanks,
Ori
PATCH v2 3/6 ethdev: add API to get hairpin peer ports list
In reply to Bing ZhaoAfter hairpin queues are configured, in general, the application will maintain the ports topology and even the queues configuration for hairpin. But sometimes it will not.
If there is no hot-plug, it is easy to bind and unbind hairpin among all the ports. The application can just connect or disconnect the hairpin egress ports to / from all the probed ingress ports. Then all the connections could be handled properly.
But with hot-plug / hot-unplug, one port could be probed and removed dynamically. With two ports hairpin, all the connections from and to this port should be handled after start(bind) or before stop(unbind). It is necessary to know the hairpin topology with this port.
This API will return the ports list with the actual peer ports number after configuration. Either peer RX or TX ports will be gotten with this function call.
--- lib/librte_ethdev/rte_ethdev.c | 24 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 27 +++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 30 ++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 4 files changed, 82 insertions(+)
lib/librte_ethdev/rte_ethdev.c +24 -0
@@ -2208,6 +2208,30 @@ struct rte_eth_dev *return ret; } +int +rte_eth_hairpin_get_peer_ports (uint16_t cur_port,uint16_t *peer_ports, +bool direction) +{ +struct rte_eth_dev *dev; +int ret; + +if (!peer_ports) +return -EINVAL ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (cur_port, -EINVAL ); + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_get_peer_ports, + -ENOTSUP ); + + ret = (*dev->dev_ops->hairpin_get_peer_ports)(dev, peer_ports, + direction); +if (ret <0 ) +RTE_ETHDEV_LOG (ERR ,"Failed to get %d hairpin peer %s ports" , + cur_port, direction ?"RX" :"TX" ); + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)
lib/librte_ethdev/rte_ethdev.h +27 -0
@@ -2134,6 +2134,33 @@ int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,* @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice * +* Get all the hairpin peer RX / TX ports of the current port. +* The caller should ensure that the array is large enough to save the ports +* list. +* +* @param cur_port +* The current port identifier of the Ethernet device. +* @param peer_ports +* Pointer to the array to save the peer ports list * +* @param direction +* Current port to peer port direction +* true - current used as TX to get all peer RX ports. +* false - current used as RX to get all peer TX ports. +* +* @return +* - (0 or positive) actual peer ports number. +* - (-EINVAL) if bad parameter. +* - (-ENOTSUP) if hardware doesn't support. +* - Others detailed errors from PMD drivers. +*/ +__rte_experimental +int rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_ports, +bool direction); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* * Bind all hairpin TX queues of one port to the RX queues of the peer port. * It is only allowed to call this API after all hairpin queues are configured * properly and the devices of TX and peer RX are in started state.
lib/librte_ethdev/rte_ethdev_driver.h +30 -0
@@ -576,6 +576,34 @@ typedef int (*eth_tx_hairpin_queue_setup_t)/** * @internal +* Get all hairpin TX/RX peer ports of the current device, if any. +* +* @param dev +* ethdev handle of port. +* @param peer_ports +* array to save the ports list. +* @param direction +* value to decide the current to peer direction +* true - used as TX to get all peer RX ports. +* false - used as RX to get all peer TX ports. +* +* @return +* Negative errno value on error, 0 or positive on success. +* +* @retval 0 +* Success, no peer ports. +* @retval >0 +* Actual number of the peer ports. +* @retval -ENOTSUP +* Get peer ports API is not supported. +* @retval -EINVAL +* One of the parameters is invalid. +*/ +typedef int (*hairpin_get_peer_ports_t )(struct rte_eth_dev *dev, +uint16_t *peer_ports,bool direction); + +/** +* @internal * Bind all hairpin TX queues of one port to the RX queues of the peer port. * * @param dev
@@ -761,6 +789,8 @@ struct eth_dev_ops {/**< Set up device RX hairpin queue. */ eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;/**< Set up device TX hairpin queue. */ +hairpin_get_peer_ports_t hairpin_get_peer_ports; +/**< Get hairpin peer ports list. */ eth_hairpin_bind_t hairpin_bind;/**< Bind all hairpin TX queues of device to the peer port RX queues. */ eth_hairpin_unbind_t hairpin_unbind;
lib/librte_ethdev/rte_ethdev_version.map +1 -0
@@ -228,6 +228,7 @@ EXPERIMENTAL { # added in 20.11 rte_eth_hairpin_bind; + rte_eth_hairpin_get_peer_ports; rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 3/6] ethdev: add API to get hairpin peer ports list
Hi Bing,
PSB,
Best,
Ori
Quoted 98 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 8, 2020 11:52 AM
Subject: [PATCH v2 3/6] ethdev: add API to get hairpin peer ports listAfter hairpin queues are configured, in general, the application will maintain the ports topology and even the queues configuration for hairpin. But sometimes it will not.
If there is no hot-plug, it is easy to bind and unbind hairpin among all the ports. The application can just connect or disconnect the hairpin egress ports to / from all the probed ingress ports. Then all the connections could be handled properly.
But with hot-plug / hot-unplug, one port could be probed and removed dynamically. With two ports hairpin, all the connections from and to this port should be handled after start(bind) or before stop(unbind). It is necessary to know the hairpin topology with this port.
This API will return the ports list with the actual peer ports number after configuration. Either peer RX or TX ports will be gotten with this function call.
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_ethdev.c | 24 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 27 +++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 30 ++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 4 files changed, 82 insertions(+)lib/librte_ethdev/rte_ethdev.c +24
-0@@ -2208,6 +2208,30 @@ struct rte_eth_dev *return ret; } +int +rte_eth_hairpin_get_peer_ports (uint16_t cur_port,uint16_t *peer_ports, +bool direction) +{ +struct rte_eth_dev *dev; +int ret; + +if (!peer_ports) +return -EINVAL ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (cur_port, -EINVAL ); + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops- >hairpin_get_peer_ports, + -ENOTSUP ); + + ret = (*dev->dev_ops->hairpin_get_peer_ports)(dev, peer_ports, + direction); +if (ret <0 ) +RTE_ETHDEV_LOG (ERR ,"Failed to get %d hairpin peer %s ports", + cur_port, direction ?"RX" :"TX" ); + +return ret; +} +void rte_eth_tx_buffer_drop_callback(struct
rte_mbuf**pkts,uint16_tunsent,lib/librte_ethdev/rte_ethdev.c +0
-0void *userdata __rte_unused)lib/librte_ethdev/rte_ethdev.h +0
-0@@ -2134,6 +2134,33 @@ int rte_eth_tx_queue_setup(uint16_t port_id,uint16_t tx_queue_id, * @warning * @b EXPERIMENTAL: this API may change, or be removed, without priornotice
*
+ * Get all the hairpin peer RX / TX ports of the current port.
+ * The caller should ensure that the array is large enough to save the ports
+ * list.
+ *
+ * @paramcur_port
+ * The current port identifier of the Ethernet device.
+ * @parampeer_ports
+ * Pointer to the array to save the peer ports list *
+ * @param direction+ * Current port to peer port direction + * true - current used as TX to get all peer RX ports. + * false - current used as RX to get all peer TX ports. + * + * @return + * - (0 or positive) actual peer ports number. + * - (-EINVAL) if bad parameter. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.+ */
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id, · line 2159
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.h +4
-0+__rte_experimental +int rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_ports, +bool direction); +
I think direction should be changed to int, or change the name to ingress, also I think we should add the peer_ports array size, so in case the application didn't allocate enough space it will simply end in error.
Quoted 72 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
* Bind all hairpin TX queues of one port to the RX queues of the peer port.
* It is only allowed to call this API after all hairpin queues are configured
* properly and the devices of TX and peer RX are in started state.lib/librte_ethdev/rte_ethdev_driver.h +30
-0@@ -576,6 +576,34 @@ typedef int (*eth_tx_hairpin_queue_setup_t)/** * @internal +* Get all hairpin TX/RX peer ports of the current device, if any. +* +* @param dev +* ethdev handle of port. +* @param peer_ports +* array to save the ports list. +* @param direction +* value to decide the current to peer direction +* true - used as TX to get all peer RX ports. +* false - used as RX to get all peer TX ports. +* +* @return +* Negative errno value on error, 0 or positive on success. +* +* @retval 0 +* Success, no peer ports. +* @retval >0 +* Actual number of the peer ports. +* @retval -ENOTSUP +* Get peer ports API is not supported. +* @retval -EINVAL +* One of the parameters is invalid. +*/ +typedef int (*hairpin_get_peer_ports_t )(struct rte_eth_dev *dev, +uint16_t *peer_ports,bool direction); + +/** +* @internal * Bind all hairpin TX queues of one port to the RX queues of the peer port. * * @param dev @@ -761,6 +789,8 @@ struct eth_dev_ops {/**< Set up device RX hairpin queue. */ eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;/**< Set up device TX hairpin queue. */ +hairpin_get_peer_ports_t hairpin_get_peer_ports; +/**< Get hairpin peer ports list. */ eth_hairpin_bind_t hairpin_bind;/**< Bind all hairpin TX queues of device to the peer port RX queues. */ eth_hairpin_unbind_t hairpin_unbind;lib/librte_ethdev/rte_ethdev_version.map +1
-1@@ -228,6 +228,7 @@ EXPERIMENTAL { # added in 20.11 rte_eth_hairpin_bind; + rte_eth_hairpin_get_peer_ports; rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; --1.8.3.1
PATCH v2 4/6 ethdev: add APIs for hairpin queue operation
In reply to Bing ZhaoEvery hairpin queue pair should be configured properly and the connection between TX and RX queues should be established, before hairpin function works. In single port hairpin mode, the queues of each pair belong to the same device. It is easy to get the hardware and software information of each queue and configure the hairpin connection with such information. In two ports hairpin mode, it is not easy or inappropriate to access one queue's information from another device.
Since hairpin is configured per queue pair, three new APIs are introduced and they are internal for the PMD using.
The peer update API helps to pass one queue's information to the peer queue and get the peer's information back for the next step. The peer bind API configures the current queue with the peer's information. For each hairpin queue pair, this API may need to be called twice to configure the TX, RX queues separately. The peer unbind API resets the current queue configuration and state to disconnect it from the peer queue. Also, it may need to be called twice to disconnect TX, RX queues from each other.
Some parameter of the above APIs might not be mandatory, and it depends on the PMD implementation.
The structure of rte_hairpin_peer_info is only a declaration and the actual members will be defined in each PMD when being used.
--- lib/librte_ethdev/rte_ethdev.c | 55 +++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 102 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 3 files changed, 160 insertions(+)
lib/librte_ethdev/rte_ethdev.c +55 -0
@@ -5459,6 +5459,61 @@ enum rte_eth_switch_domain_state {return 0 ; } +int +rte_eth_hairpin_queue_peer_update (uint16_t peer_port,uint16_t peer_queue, +struct rte_hairpin_peer_info *cur_info, +struct rte_hairpin_peer_info *peer_info, +bool direction) +{ +struct rte_eth_dev *dev; + +/* Current queue information is not mandatory. */ +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[peer_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_update, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_update)(dev, peer_queue, + cur_info, peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_bind (uint16_t cur_port,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info, +bool direction) +{ +struct rte_eth_dev *dev; + +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_bind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_bind)(dev, cur_queue, + peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_unbind (uint16_t cur_port,uint16_t cur_queue, +bool direction) +{ +struct rte_eth_dev *dev; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_unbind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_unbind)(dev, cur_queue, + direction); +} +RTE_LOG_REGISTER (rte_eth_dev_logtype, lib.ethdev,INFO );RTE_INIT (ethdev_init_telemetry)
lib/librte_ethdev/rte_ethdev_driver.h +102 -0
126 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -251,6 +251,9 @@ INTERNAL { rte_eth_devargs_parse; rte_eth_dma_zone_free; rte_eth_dma_zone_reserve; + rte_eth_hairpin_queue_peer_bind; + rte_eth_hairpin_queue_peer_unbind; + rte_eth_hairpin_queue_peer_update; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; rte_flow_expand_rss;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 4/6] ethdev: add APIs for hairpin queue operation
Hi Bing,
Quoted 26 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 8, 2020 11:52 AM
Subject: [PATCH v2 4/6] ethdev: add APIs for hairpin queue operationEvery hairpin queue pair should be configured properly and the connection between TX and RX queues should be established, before hairpin function works. In single port hairpin mode, the queues of each pair belong to the same device. It is easy to get the hardware and software information of each queue and configure the hairpin connection with such information. In two ports hairpin mode, it is not easy or inappropriate to access one queue's information from another device.
Since hairpin is configured per queue pair, three new APIs are introduced and they are internal for the PMD using.
The peer update API helps to pass one queue's information to the peer queue and get the peer's information back for the next step. The peer bind API configures the current queue with the peer's information. For each hairpin queue pair, this API may need to be called twice to configure the TX, RX queues separately. The peer unbind API resets the current queue configuration and state to disconnect it from the peer queue. Also, it may need to be called twice to disconnect TX, RX queues from each other.
Quoted 8 lines
Some parameter of the above APIs might not be mandatory, and it depends on the PMD implementation.
The structure of
rte_hairpin_peer_infois only a declaration and the actual members will be defined in each PMD when being used.Signed-off-by Bing Zhao <[email protected]>---
Thanks,
Ori
PATCH v2 5/6 app/testpmd: change hairpin queues setup
In reply to Bing ZhaoA new parameter hairpin-mode is introduced to the testpmd command line. Bitmask value is used to provide more flexible configuration. This parameter should be used when hairpinq is specified in the command line.
Bit 0 in the LSB indicates the hairpin will use the loop mode. The previous port RX queue will be connected to the current port TX queue.
Bit 1 in the LSB indicates the hairpin will use pair port mode. The even index port will be paired with the next odd index port. If the total number of probed port is odd, then the last one will be paired to itself.
If this byte is zero, then each port will be paired to itself. Bit 0 takes a higher priority in the checking.
Bit 4 in the second bytes indicate if the hairpin will use explicit TX flow mode.
e.g. in the command line, "--hairpinq=2 --hairpin-mode=0x11"
If not set, default value zero will be used and the behavior will try to get align with the previous single port mode. If the ports belong to different vendors' NICs, it is suggested to use the self hairpin mode only.
Since hairpin configures the hardware resources, the port mask of packets forwarding engine will not be used here.
---
v2: move the hairpin bind/unbind into start/stop to support hot-plug
and hot-unplug
--- app/test-pmd/parameters.c | 15 ++++++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++++++++++++++++++++++++++-- app/test-pmd/testpmd.h | 2 + 3 files changed, 138 insertions(+), 4 deletions(-)
app/test-pmd/parameters.c +15 -0
@@ -221,6 +221,9 @@ "enabled\n");printf (" --record-core-cycles: enable measurement of CPU cycles.\n" );printf (" --record-burst-stats: enable display of RX and TX bursts.\n" ); +printf (" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n " +" 0x10 - explicit tx rule, 0x02 - hairpin ports paired\n" +" 0x01 - hairpin ports loop, 0x00 - hairpin port self\n" ); }#ifdef RTE_LIBRTE_CMDLINE
@@ -644,6 +647,7 @@ { "rxd", 1, 0, 0 }, { "txd", 1, 0, 0 }, { "hairpinq", 1, 0, 0 }, + { "hairpin-mode", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 },
@@ -1111,6 +1115,17 @@rte_exit (EXIT_FAILURE ,"Either rx or tx queues should " "be non-zero\n" ); } +if (!strcmp (lgopts[opt_idx].name,"hairpin-mode" )) { +char *end =NULL ; +unsigned int n; + + errno =0 ; + n =strtoul (optarg, &end,0 ); +if (errno !=0 || end == optarg) +rte_exit (EXIT_FAILURE ,"hairpin mode invalid\n" ); +else + hairpin_mode = (uint16_t )n; + }if (!strcmp (lgopts[opt_idx].name,"burst" )) { n =atoi (optarg);if (n ==0 ) {
app/test-pmd/testpmd.c +121 -4
195 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -398,6 +398,8 @@ struct queue_stats_mappings {extern uint16_t stats_period; +extern uint16_t hairpin_mode; +#ifdef RTE_LIBRTE_LATENCY_STATS extern uint8_t latencystats_enabled;extern lcoreid_t latencystats_lcore_id;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 5/6] app/testpmd: change hairpin queues setup
Hi Bing
Quoted 30 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 8, 2020 11:52 AM
Subject: [PATCH v2 5/6] app/testpmd: change hairpin queues setupA new parameter
hairpin-modeis introduced to the testpmd command line. Bitmask value is used to provide more flexible configuration. This parameter should be used whenhairpinqis specified in the command line.Bit 0 in the LSB indicates the hairpin will use the loop mode. The previous port RX queue will be connected to the current port TX queue.
Bit 1 in the LSB indicates the hairpin will use pair port mode. The even index port will be paired with the next odd index port. If the total number of probed port is odd, then the last one will be paired to itself.
If this byte is zero, then each port will be paired to itself. Bit 0 takes a higher priority in the checking.Bit 4 in the second bytes indicate if the hairpin will use explicit TX flow mode.
e.g. in the command line, "--hairpinq=2 --hairpin-mode=0x11"
If not set, default value zero will be used and the behavior will try to get align with the previous single port mode. If the ports belong to different vendors' NICs, it is suggested to use the
selfhairpin mode only.
Quoted 8 lines
Since hairpin configures the hardware resources, the port mask of packets forwarding engine will not be used here.
Signed-off-by Bing Zhao <[email protected]>---
v2: move the hairpin bind/unbind into start/stop to support hot-plug
and hot-unplug
---
Thanks,
Ori
PATCH v2 6/6 doc: update for two ports hairpin mode
In reply to Bing ZhaoIn the release notes, 2 ports hairpin mode feature is added.
In rte flow part, one suggestion is added to mention that metadata could be used to connect the hairpin RX and TX flows if the hairpin is working in explicit TX flow rule mode.
In the testpmd command line, the new parameter to set hairpin working mode is described.
--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++ 3 files changed, 19 insertions(+)
doc/guides/prog_guide/rte_flow.rst +3 -0
@@ -2592,6 +2592,9 @@ set, unpredictable value will be seen depending on driver implementation. For loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to the other path depending on HW capability. +In hairpin case with TX explicit flow mode, metadata could (not mandatory) be +used to connect the RX and TX flows if it can be propagated from RX to TX path. + .. _table_rte_flow_action_set_meta: .. table:: SET_META
doc/guides/rel_notes/release_20_11.rst +8 -0
@@ -109,6 +109,10 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Updated the ethdev library to support hairpin between two ports.** + + New APIs are introduced to support binding / unbinding 2 ports hairpin. + Hairpin TX part flow rules can be inserted explicitly. Removed Items -------------
@@ -240,6 +244,10 @@ ABI Changes * ``ethdev`` internal functions are marked with ``__rte_internal`` tag. + * ``struct rte_eth_hairpin_conf`` has two new members: + + * ``uint32_t tx_explicit:1;`` + * ``uint32_t manual_bind:1;`` Known Issues ------------
doc/guides/testpmd_app_ug/run_app.rst +8 -0
@@ -497,3 +497,11 @@ The command line options are: * ``--record-burst-stats`` Enable display of RX and TX burst stats. + +* ``--hairpin-mode=0xXX`` + + Set the hairpin port mode with bitmask, only valid when hairpin queues number is set. + bit 4 - explicit TX flow rule + bit 1 - two hairpin ports paired + bit 0 - two hairpin ports loop + The default value is 0. Hairpin will use single port mode and implicit TX flow mode.
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v2 6/6] doc: update for two ports hairpin mode
Hi Bing,
Quoted 84 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 8, 2020 11:52 AM
Subject: [PATCH v2 6/6] doc: update for two ports hairpin modeIn the release notes, 2 ports hairpin mode feature is added.
In rte flow part, one suggestion is added to mention that metadata could be used to connect the hairpin RX and TX flows if the hairpin is working in explicit TX flow rule mode.
In the testpmd command line, the new parameter to set hairpin working mode is described.
Signed-off-by Bing Zhao <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++ 3 files changed, 19 insertions(+)doc/guides/prog_guide/rte_flow.rst +0
-0@@ -2592,6 +2592,9 @@ set, unpredictable value will be seen depending ondriver implementation. For
loopback/hairpin packet, metadata set on Rx/Tx may or may not be
propagated to
the other path depending on HW capability.doc/guides/prog_guide/rte_flow.rst +2
-0+In hairpin case with TX explicit flow mode, metadata could (not mandatory) be +used to connect the RX and TX flows if it can be propagated from RX to TXpath.
doc/guides/prog_guide/rte_flow.rst +1
-0+ .. _table_rte_flow_action_set_meta: .. table:: SET_METAdoc/guides/rel_notes/release_20_11.rst +8
-0@@ -109,6 +109,10 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Updated the ethdev library to support hairpin between two ports.** + + New APIs are introduced to support binding / unbinding 2 ports hairpin. + Hairpin TX part flow rules can be inserted explicitly. Removed Items -------------@@ -240,6 +244,10 @@ ABI Changes * ``ethdev`` internal functions are marked with ``__rte_internal`` tag. + * ``struct rte_eth_hairpin_conf`` has two new members: + + * ``uint32_t tx_explicit:1;`` + * ``uint32_t manual_bind:1;`` Known Issues ------------doc/guides/testpmd_app_ug/run_app.rst +4
-0@@ -497,3 +497,11 @@ The command line options are: * ``--record-burst-stats`` Enable display of RX and TX burst stats. + +* ``--hairpin-mode=0xXX`` + + Set the hairpin port mode with bitmask, only valid when hairpin queuesnumber is set.
doc/guides/testpmd_app_ug/run_app.rst +4
-0+ bit 4 - explicit TX flow rule + bit 1 - two hairpin ports paired + bit 0 - two hairpin ports loop + The default value is 0. Hairpin will use single port mode and implicit TX flow
Quoted 3 lines
mode.
--
1.8.3.1
Thanks,
Ori
v3 cover introduce support for hairpin between two ports
In reply to Bing ZhaoThe patches contain the following changes:
1. new APIs to bind and unbind hairpin ports in manual binding mode.
2. new API to get the hairpin peer ports list.
3. new internal APIs for PMD to pass the queue information and configure the queue pair.
4. new attribute members in the hairpin queue configuraiton structure to specify the binding mode and enable explicit TX flow mode.
5. Testpmd support to configure the hairpin modes for two ports hairpin verification.
6. documents update.
---
v3:
1. add length to protect the pointer to the array from getting corrupted
2. change the direction from bool to unsigned int
v2:
1. add documents update
2. remove all peer ports logic from rte API
3. conf structure optimizing
4. new API to get the peer ports and testpmd change to support hot-plug / unplug case
---
Bing Zhao (6):
ethdev: add hairpin bind and unbind APIs
ethdev: add new attributes to hairpin config
ethdev: add API to get hairpin peer ports list
ethdev: add APIs for hairpin queue operation
app/testpmd: change hairpin queues setup
doc: update for two ports hairpin mode
app/test-pmd/parameters.c | 15 +++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++- app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 3 + doc/guides/rel_notes/release_20_11.rst | 8 ++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++ lib/librte_ethdev/rte_ethdev.c | 133 +++++++++++++++++++++- lib/librte_ethdev/rte_ethdev.h | 85 +++++++++++++- lib/librte_ethdev/rte_ethdev_driver.h | 187 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 6 + 10 files changed, 563 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 1/6 ethdev: add hairpin bind and unbind APIs
In single port hairpin mode, all the hairpin TX and RX queues belong to the same device. After the queues are set up properly, there is no other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized already for the binding process.
But in two ports hairpin mode, there will be some cross-dependences between two different ports. Usually, the ports will be initialized serially by the main thread but not in parallel. The earlier port will not be able to enable the bind if the following peer port is not yet configured with HW resources. What's more, if one port is detached / attached dynamically, it would introduce more trouble for the hairpin binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set up. Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the rte_eth_hairpin_bind() API can be called to bind the all TX queues of the egress port to the RX queues of the peer port. Then the connection between the egress and ingress ports pair will be established.
The rte_eth_hairpin_unbind() API could be used to disconnect the egress and the peer ingress ports. This should only be called before the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken into consideration, especially in the hot unplug case.
---
v2: remove the all peer ports logic from rte API
--- lib/librte_ethdev/rte_ethdev.c | 46 ++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 51 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 ++ 4 files changed, 151 insertions(+)
lib/librte_ethdev/rte_ethdev.c +46 -0
@@ -2162,6 +2162,52 @@ struct rte_eth_dev *return eth_err (port_id, ret); } +int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +int ret; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is not started" , tx_port); +return -EBUSY ; + } + +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_bind, -ENOTSUP ); + ret = (*dev->dev_ops->hairpin_bind)(dev, rx_port); +if (ret) +RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX %d " +"to RX %d (%d - all ports)" , tx_port, + rx_port,RTE_MAX_ETHPORTS ); + +return ret; +} + +int +rte_eth_hairpin_unbind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +int ret; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL ); + dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is already stopped" , tx_port); +return -EBUSY ; + } + +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_unbind, -ENOTSUP ); + ret = (*dev->dev_ops->hairpin_unbind)(dev, rx_port); +if (ret) +RTE_ETHDEV_LOG (ERR ,"Failed to unbind hairpin " +"TX %d from RX %d (%d - all ports)" , tx_port, + rx_port,RTE_MAX_ETHPORTS ); + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)
lib/librte_ethdev/rte_ethdev.h +51 -0
57 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_driver.h +52 -0
64 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +2 -0
@@ -227,6 +227,8 @@ EXPERIMENTAL { rte_tm_wred_profile_delete; # added in 20.11 + rte_eth_hairpin_bind; + rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; };
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add hairpin bind and unbind APIs
Hi,
Cosmetic comments below:
08/10/2020 14:05, Bing Zhao:
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2171
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +7
-0+int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) +{ +struct rte_eth_dev *dev; +int ret; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL );
It should be -ENODEV
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2183
Quoted 12 lines
lib/librte_ethdev/rte_ethdev.c +12
-0+ dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { +RTE_ETHDEV_LOG (ERR ,"TX port %d is not started" , tx_port); +return -EBUSY ; + } + +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_bind, -ENOTSUP ); + ret = (*dev->dev_ops->hairpin_bind)(dev, rx_port); +if (ret) +RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX %d " +"to RX %d (%d - all ports)" , tx_port, + rx_port,RTE_MAX_ETHPORTS );
Looks like \n is missing.
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2189
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+ +return ret; +} + +int +rte_eth_hairpin_unbind (uint16_t tx_port,uint16_t rx_port)
Same comments as for bind function.
[...]
Quoted 7 lines
/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Bind all hairpin TX queues of one port to the RX queues of the peer port.
+ * It is only allowed to call this API after all hairpin queues are configured
+ * properly and the devices of TX and peer RX are in started state.
"call this API" -> "call this function"
"devices of TX" is a strange wording.
I would make it simpler:
"the devices of TX and peer RX" -> "the devices"
Quoted 3 lines
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.
A device does not have a TX port.
I think you mean "The identifier of the TX port."
Quoted 2 lines
+ * @param
rx_port
+ * The peer RX port identifier of the Ethernet device.
Remove "of the Ethernet device"
Quoted 2 lines
+ *
RTE_MAX_ETHPORTSis allowed for the traversal of all devices.
+ * RX port ID could have the same value with TX port ID.
"same value as"
Quoted 7 lines
+ *
+ * @return+ * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is not in started state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.
Please add ENODEV case, maybe instead of EINVAL.
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id, · line 2160
Quoted 10 lines
+ */
lib/librte_ethdev/rte_ethdev.h +9
-0+__rte_experimental +int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* +* Unbind all hairpin TX queues of one port from the RX queues of the peer port. +* This should be called before closing the TX or RX devices (optional). After
Split the line after the end of sentence and start next one on a fresh line.
Quoted 1 line
+ * unbind the hairpin ports pair, it is allowed to bind them again.
"unbind" -> "unbinding"
Quoted 5 lines
+ * Changing queues configuration should be after stopping the device.
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.
+ * @paramrx_port
Quoted 10 lines
+ * The peer RX port identifier of the Ethernet device. + * RTE_MAX_ETHPORTS is allowed for traversal of all devices. + * RX port ID could have the same value with TX port ID. + * + * @return + * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is in stopped state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.
Same comments as for the bind function.
Quoted 3 lines
+ */
(quoted diff) +2
-0+__rte_experimental +int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add hairpin bind and unbind APIs
Hi Thomas,
Quoted 18 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 14, 2020 10:36 PM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add hairpin bind and unbind APIsExternal email: Use caution opening links or attachments
Hi,
Cosmetic comments below:08/10/2020 14:05, Bing Zhao:
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2171
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) { +struct rte_eth_dev *dev; +int ret; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL );It should be
-ENODEV
Got it, changed. BTW, I checked the ethdev and it seems some functions are using "EINVAL" and some are using "ENODEV". So should all of these functions use "ENODEV"?
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +3
-0+ dev = &rte_eth_devices[tx_port]; +if (!dev->data->dev_started) { + RTE_ETHDEV_LOG(ERR, "TX port %d is not started",
tx_port);lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *
Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +4
-0+return -EBUSY ; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->hairpin_bind, -
Quoted 8 lines
ENOTSUP);
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2183
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +5
-0+ ret = (*dev->dev_ops->hairpin_bind)(dev, rx_port); +if (ret) +RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX %d " +"to RX %d (%d - all ports)" , tx_port, + rx_port,RTE_MAX_ETHPORTS );Looks like \n is missing.
Fixed, thanks.
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2189
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+ +return ret; +} + +int +rte_eth_hairpin_unbind (uint16_t tx_port,uint16_t rx_port)Same comments as for bind function.
Done.
Quoted 9 lines
[...]
Quoted 3 lines
/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, withoutprior
Quoted 3 lines
+ notice
+ *
+ * Bind all hairpin TX queues of one port to the RX queues of the
Quoted 8 lines
peer port.
Quoted 1 line
+ * It is only allowed to call this API after all hairpin queues
are
Quoted 2 lines
+ configured
+ * properly and the devices of TX and peer RX are in startedstate.
"call this API" -> "call this function"
Done.
Quoted 11 lines
"devices of TX" is a strange wording.
I would make it simpler:
"the devices of TX and peer RX" -> "the devices"Quoted 3 lines
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.A device does not have a TX port.
I think you mean "The identifier of the TX port."
Done.
Quoted 5 lines
Quoted 3 lines
+ * @param
rx_port
+ * The peer RX port identifier of the Ethernet device.Remove "of the Ethernet device"
Done.
Quoted 5 lines
Quoted 3 lines
+ *
RTE_MAX_ETHPORTSis allowed for the traversal of all devices.
+ * RX port ID could have the same value with TX port ID."same value as"
Done.
Quoted 10 lines
Quoted 8 lines
+ *
+ * @return+ * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is not in started state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.Please add ENODEV case, maybe instead of EINVAL.
Replaced. PMD may return -EINVAL but it is not necessary so I will not list it here anymore.
Quoted 12 lines
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
Quoted 8 lines
+ */
lib/librte_ethdev/rte_ethdev.h +6
-0+__rte_experimental +int rte_eth_hairpin_bind(uint16_t tx_port, uint16_t rx_port); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior
Quoted 3 lines
+notice
+ *
+ * Unbind all hairpin TX queues of one port from the RX queues of
Quoted 7 lines
the peer port.
Quoted 2 lines
+ * This should be called before closing the TX or RX devices +(optional). After
Split the line after the end of sentence and start next one on a fresh line.
Done
Quoted 4 lines
Quoted 1 line
+ * unbind the hairpin ports pair, it is allowed to bind them
again.
"unbind" -> "unbinding"
Done
Quoted 18 lines
Quoted 2 lines
+ * Changing queues configuration should be after stopping the
device.
Quoted 4 lines
+ *
+ * @paramtx_port
+ * The TX port identifier of the Ethernet device.
+ * @paramrx_portQuoted 10 lines
+ * The peer RX port identifier of the Ethernet device. + * RTE_MAX_ETHPORTS is allowed for traversal of all devices. + * RX port ID could have the same value with TX port ID. + * + * @return + * - (0) if successful. + * - (-EINVAL) if bad parameter. + * - (-EBUSY) if device is in stopped state. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.
Quoted 1 line
Same comments as for the bind function.
Done.
Quoted 6 lines
Review
Quoted 4 lines
+ */
(quoted diff) +2
-0+__rte_experimental +int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);
Thanks a lot
Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add hairpin bind and unbind APIs
15/10/2020 04:56, Bing Zhao:
Quoted 11 lines
From: Thomas Monjalon <[email protected]>
Quoted 9 lines
08/10/2020 14:05, Bing Zhao:
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2171
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.c +6
-0+int +rte_eth_hairpin_bind (uint16_t tx_port,uint16_t rx_port) { +struct rte_eth_dev *dev; +int ret; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (tx_port, -EINVAL );It should be
-ENODEV
Quoted 1 line
Got it, changed. BTW, I checked the ethdev and it seems some functions are using "EINVAL" and some are using "ENODEV". So should all of these functions use "ENODEV"?
Yes there is a patch pending to return ENODEV everywhere:
https://patches.dpdk.org/patch/80568/
PATCH v3 2/6 ethdev: add new attributes to hairpin config
In reply to Bing ZhaoTo support two ports hairpin mode and keep the backward compatibility for the application, two new attribute members of hairpin queue configuration structure are added.
tx_explicit means if the application itself will insert the TX part flow rules. If not set, PMD will insert the rules implicitly. manual_bind means if the hairpin TX queue and peer RX queue will be bound automatically during device start stage.
Different TX and RX queue pairs could have different values, but it is highly recommended that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD drivers.
In a single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means no bind API needs to be called and no TX flow rules need to be inserted manually by the application.
---
v2: optimize the structure and remove unused macros
--- lib/librte_ethdev/rte_ethdev.c | 8 ++++---- lib/librte_ethdev/rte_ethdev.h | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-)
lib/librte_ethdev/rte_ethdev.c +4 -4
@@ -1954,13 +1954,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_rx_2_tx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Rx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_rx_2_tx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Rx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
@@ -2125,13 +2125,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_tx_2_rx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Tx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_tx_2_rx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Tx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
lib/librte_ethdev/rte_ethdev.h +4 -1
@@ -1045,7 +1045,10 @@ struct rte_eth_hairpin_peer {* A structure used to configure hairpin binding. */ struct rte_eth_hairpin_conf { -uint16_t peer_count;/**< The number of peers. */ +uint32_t peer_count:16 ;/**< The number of peers. */ +uint32_t tx_explicit:1 ;/**< Explicit TX flow rule mode. */ +uint32_t manual_bind:1 ;/**< Manually bind hairpin queues. */ +uint32_t reserved:14 ;/**< Reserved bits. */ struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; };
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v3 2/6] ethdev: add new attributes to hairpin config
08/10/2020 14:05, Bing Zhao:
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer { · line 1048
Quoted 3 lines
struct
rte_eth_hairpin_conf{lib/librte_ethdev/rte_ethdev.h +1
-1-uint16_t peer_count;/**< The number of peers. */ + uint32_t peer_count:16; /**< The number of peers. */
Why not keeping uint16_t?
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer { · line 1050
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.h +2
-0+ uint32_t tx_explicit:1; /**< Explicit TX flow rule mode. */ + uint32_t manual_bind:1; /**< Manually bind hairpin queues. */
Please describe more the expectations of these bits:
What is changed at ethdev or PMD level?
What the application is supposed to do?
Why choosing one mode or the other?
Re: [dpdk-dev] [PATCH v3 2/6] ethdev: add new attributes to hairpin config
Hi Thomas,
PSB
Quoted 14 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 13, 2020 5:37 AM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 2/6] ethdev: add new attributes to hairpin configExternal email: Use caution opening links or attachments
Quoted 6 lines
08/10/2020 14:05, Bing Zhao:
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer { · line 1048
Quoted 3 lines
struct
rte_eth_hairpin_conf{lib/librte_ethdev/rte_ethdev.h +1
-1-uint16_t peer_count;/**< The number of peers. */ + uint32_t peer_count:16; /**< The number of peers. */Why not keeping
uint16_t?
The inside structure has a multiple of 4B, and the peer_count now only takes about 2B. AFAIK, usually, the structure will have an aligned length/offset and there will be some padding between the 2B + (2B pad) + 4B * 32 or 2B + (2B +2B) * 32 + 2B, depending on the compiler. I changed to bit fields of a u32 due to the two facts:
1. Using the 2B and keep the whole structure aligned. No waste except the reserved bits.
2. Only u32 with bit fields is standard.
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ uint32_t tx_explicit:1; /**< Explicit TX flow rule mode. */ + uint32_t manual_bind:1; /**< Manually bind hairpin queues.*/
Please describe more the expectations of these bits:
What is changed at ethdev or PMD level?
In ethdev level, there is almost no change. This attribute will be passed to PMD directly through the function pointer.
In PMD level, these bits should be checked and better to be saved. And the attribute fields should be checked for per queue pair and all the queues, and each queue pair should have the same attributes configured to make the behavior aligned. But it depends on the PMD itself to decide if all the queue pairs between a port pair should have the same attributes, or even all the queues from / to same port of all hairpin port pairs. If manual_bind is not set, then the PMD will try to bind the queues and enable hairpin during device start stage and there is no need to call the bind / unbind API.
If tx_explicit is set, the application should insert the RX flow rules and TX flow rules seperataly and connect the RX/TX logic connection together.
Quoted 1 line
What the application is supposed to do?
The application should specify the new two attributes during the queue setup. And also, it could leave it unset (0 by default) to keep the behavior compatible with the previous release.
If manual_bind is set, then it is the application's responsibility to call the bind / unbind API to enable / disable the hairpin between specific ports.
If tx_explicit is set, as described above, the application should maintain the flows logic to make hairpin work as expected, e.g., they can choose metadata (not the only method), in the RX flow, the metadata is set and in the TX flow, it is used for matching. Then even if the headers are changed with NAT action or encap, the hairpin function could work as expected.
Quoted 1 line
Why choosing one mode or the other?
If the application wants to have the full control of hairpin flows, it could chose the explicit TX flow mode. If two or more ports involved into the hairpin, it is suggested to use the manual bind. Please note, the actual supported attributes denpend on the PMD and HW.
Quoted 1 line
Thanks
Re: [dpdk-dev] [PATCH v3 2/6] ethdev: add new attributes to hairpin config
13/10/2020 14:29, Bing Zhao:
Quoted 6 lines
From: Thomas Monjalon <[email protected]>
Quoted 5 lines
08/10/2020 14:05, Bing Zhao:
Quoted 3 lines
struct
rte_eth_hairpin_conf{lib/librte_ethdev/rte_ethdev.h +1
-1-uint16_t peer_count;/**< The number of peers. */ + uint32_t peer_count:16; /**< The number of peers. */
Quoted 6 lines
Quoted 1 line
Why not keeping
uint16_t?The inside structure has a multiple of 4B, and the
peer_countnow only takes about 2B. AFAIK, usually, the structure will have an aligned length/offset and there will be some padding between the 2B + (2B pad) + 4B * 32 or 2B + (2B +2B) * 32 + 2B, depending on the compiler. I changed to bit fields of a u32 due to the two facts:
1. Using the 2B and keep the whole structure aligned. No waste except the reserved bits.
2. Only u32 with bit fields is standard.
Oh I see, this is because u16 bit fields are not standard?
Quoted 18 lines
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ uint32_t tx_explicit:1; /**< Explicit TX flow rule mode. */ + uint32_t manual_bind:1; /**< Manually bind hairpin queues.*/
Please describe more the expectations of these bits:
What is changed at ethdev or PMD level?In ethdev level, there is almost no change. This attribute will be passed to PMD directly through the function pointer.
In PMD level, these bits should be checked and better to be saved. And the attribute fields should be checked for per queue pair and all the queues, and each queue pair should have the same attributes configured to make the behavior aligned. But it depends on the PMD itself to decide if all the queue pairs between a port pair should have the same attributes, or even all the queues from / to same port of all hairpin port pairs. Ifmanual_bindis not set, then the PMD will try to bind the queues and enable hairpin during device start stage and there is no need to call the bind / unbind API.
Iftx_explicitis set, the application should insert the RX flow rules and TX flow rules seperataly and connect the RX/TX logic connection together.Quoted 1 line
What the application is supposed to do?
The application should specify the new two attributes during the queue setup. And also, it could leave it unset (0 by default) to keep the behavior compatible with the previous release.
Ifmanual_bindis set, then it is the application's responsibility to call the bind / unbind API to enable / disable the hairpin between specific ports.
Iftx_explicitis set, as described above, the application should maintain the flows logic to make hairpin work as expected, e.g., they can choose metadata (not the only method), in the RX flow, the metadata is set and in the TX flow, it is used for matching. Then even if the headers are changed with NAT action or encap, the hairpin function could work as expected.
Quoted 5 lines
Quoted 1 line
Why choosing one mode or the other?
If the application wants to have the full control of hairpin flows, it could chose the explicit TX flow mode. If two or more ports involved into the hairpin, it is suggested to use the manual bind. Please note, the actual supported attributes denpend on the PMD and HW.
The application impact must be described shortly in doxygen please.
Re: [dpdk-dev] [PATCH v3 2/6] ethdev: add new attributes to hairpin config
Hi Thomas,
Quoted 28 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 13, 2020 8:42 PM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 2/6] ethdev: add new attributes to hairpin configExternal email: Use caution opening links or attachments
13/10/2020 14:29, Bing Zhao:
Quoted 9 lines
From: Thomas Monjalon <[email protected]>
Quoted 6 lines
08/10/2020 14:05, Bing Zhao:
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer { · line 1048
Quoted 3 lines
struct
rte_eth_hairpin_conf{lib/librte_ethdev/rte_ethdev.h +1
-1-uint16_t peer_count;/**< The number of peers. */ + uint32_t peer_count:16; /**< The number of peers. */Why not keeping
uint16_t?The inside structure has a multiple of 4B, and the
peer_countnowonly takes about 2B. AFAIK, usually, the structure will have an aligned length/offset and there will be some padding between the 2B
+ (2B pad) + 4B * 32 or 2B + (2B +2B) * 32 + 2B, depending on the compiler.
Quoted 6 lines
Quoted 2 lines
I changed to bit fields of a u32 due to the two facts:
1. Using the 2B and keep the whole structure aligned. No wasteexcept the reserved bits.
Quoted 1 line
2. Only u32 with bit fields is standard.
Oh I see, this is because u16 bit fields are not standard?
In some compiler, it is supported. But in the old compiler, it might not and some warning will be raised. " nonstandard extension used : bit-field types other than int "
"
The following properties of bit fields are implementation-defined:
Whether bit fields of type int are treated as signed or unsigned
Whether types other than int, signed int, unsigned int, and _Bool (since C99) are permitted "
In C11, it should be supported already.
Quoted 43 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+
uint32_ttx_explicit:1; /**< Explicit TX flow rule mode.*/
Quoted 1 line
Quoted 1 line
Quoted 1 line
+
uint32_tmanual_bind:1; /**< Manually bind hairpinqueues.
Quoted 6 lines
Quoted 4 lines
*/
Please describe more the expectations of these bits:
What is changed at ethdev or PMD level?In ethdev level, there is almost no change. This attribute will be
passed to PMD directly through the function pointer.
Quoted 1 line
In PMD level, these bits should be checked and better to be saved.
And the attribute fields should be checked for per queue pair and all the queues, and each queue pair should have the same attributes configured to make the behavior aligned. But it depends on the PMD itself to decide if all the queue pairs between a port pair should have the same attributes, or even all the queues from / to same port of all hairpin port pairs.
Quoted 1 line
If
manual_bindis not set, then the PMD will try to bind thequeues and enable hairpin during device start stage and there is no need to call the bind / unbind API.
Quoted 1 line
If
tx_explicitis set, the application should insert the RX flowrules and TX flow rules separately and connect the RX/TX logic connection together.
Quoted 4 lines
Quoted 2 lines
What the application is supposed to do?
The application should specify the new two attributes during the
queue setup. And also, it could leave it unset (0 by default) to keep the behavior compatible with the previous release.
Quoted 1 line
If
manual_bindis set, then it is the application's responsibilityto call the bind / unbind API to enable / disable the hairpin between specific ports.
Quoted 1 line
If
tx_explicitis set, as described above, the application shouldmaintain the flows logic to make hairpin work as expected, e.g., they can choose metadata (not the only method), in the RX flow, the metadata is set and in the TX flow, it is used for matching. Then even if the headers are changed with NAT action or encap, the hairpin function could work as expected.
Quoted 3 lines
Quoted 2 lines
Why choosing one mode or the other?
Quoted 10 lines
Quoted 1 line
If the application wants to have the full control of hairpin flows,
it could chose the explicit TX flow mode.
Quoted 1 line
If two or more ports involved into the hairpin, it is suggested to
use the manual bind.
Quoted 1 line
Please note, the actual supported attributes denpend on the PMD
and HW.
The application impact must be described shortly in doxygen please.
OK, sure. I added into the commit message. I will also describe it shortly in the doc.
Thanks
PATCH v3 3/6 ethdev: add API to get hairpin peer ports list
In reply to Bing ZhaoAfter hairpin queues are configured, in general, the application will maintain the ports topology and even the queues configuration for hairpin. But sometimes it will not.
If there is no hot-plug, it is easy to bind and unbind hairpin among all the ports. The application can just connect or disconnect the hairpin egress ports to / from all the probed ingress ports. Then all the connections could be handled properly.
But with hot-plug / hot-unplug, one port could be probed and removed dynamically. With two ports hairpin, all the connections from and to this port should be handled after start(bind) or before stop(unbind). It is necessary to know the hairpin topology with this port.
This API will return the ports list with the actual peer ports number after configuration. Either peer RX or TX ports will be gotten with this function call.
---
v3:
1. change the direction from bool to unsigned int type
2. add length to protect the array from getting corrupted
--- lib/librte_ethdev/rte_ethdev.c | 24 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 29 ++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 33 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 4 files changed, 87 insertions(+)
lib/librte_ethdev/rte_ethdev.c +24 -0
@@ -2208,6 +2208,30 @@ struct rte_eth_dev *return ret; } +int +rte_eth_hairpin_get_peer_ports (uint16_t cur_port,uint16_t *peer_ports, +size_t len,uint32_t direction) +{ +struct rte_eth_dev *dev; +int ret; + +if (!peer_ports || !len) +return -EINVAL ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (cur_port, -EINVAL ); + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_get_peer_ports, + -ENOTSUP ); + + ret = (*dev->dev_ops->hairpin_get_peer_ports)(dev, peer_ports, + len, direction); +if (ret <0 ) +RTE_ETHDEV_LOG (ERR ,"Failed to get %d hairpin peer %s ports" , + cur_port, direction ?"RX" :"TX" ); + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)
lib/librte_ethdev/rte_ethdev.h +29 -0
@@ -2134,6 +2134,35 @@ int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,* @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice * +* Get all the hairpin peer RX / TX ports of the current port. +* The caller should ensure that the array is large enough to save the ports +* list. +* +* @param cur_port +* The current port identifier of the Ethernet device. +* @param peer_ports +* Pointer to the array to store the peer ports list. +* @param len +* Length of the array to store the port identifiers. +* @param direction +* Current port to peer port direction +* positive - current used as TX to get all peer RX ports. +* zero - current used as RX to get all peer TX ports. +* +* @return +* - (0 or positive) actual peer ports number. +* - (-EINVAL) if bad parameter. +* - (-ENOTSUP) if hardware doesn't support. +* - Others detailed errors from PMD drivers. +*/ +__rte_experimental +int rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_ports, +size_t len,uint32_t direction); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* * Bind all hairpin TX queues of one port to the RX queues of the peer port. * It is only allowed to call this API after all hairpin queues are configured * properly and the devices of TX and peer RX are in started state.
lib/librte_ethdev/rte_ethdev_driver.h +33 -0
@@ -576,6 +576,37 @@ typedef int (*eth_tx_hairpin_queue_setup_t)/** * @internal +* Get all hairpin TX/RX peer ports of the current device, if any. +* +* @param dev +* ethdev handle of port. +* @param peer_ports +* array to save the ports list. +* @param len +* array length. +* @param direction +* value to decide the current to peer direction +* positive - used as TX to get all peer RX ports. +* zero - used as RX to get all peer TX ports. +* +* @return +* Negative errno value on error, 0 or positive on success. +* +* @retval 0 +* Success, no peer ports. +* @retval >0 +* Actual number of the peer ports. +* @retval -ENOTSUP +* Get peer ports API is not supported. +* @retval -EINVAL +* One of the parameters is invalid. +*/ +typedef int (*hairpin_get_peer_ports_t )(struct rte_eth_dev *dev, +uint16_t *peer_ports,size_t len, +uint32_t direction); + +/** +* @internal * Bind all hairpin TX queues of one port to the RX queues of the peer port. * * @param dev
@@ -761,6 +792,8 @@ struct eth_dev_ops {/**< Set up device RX hairpin queue. */ eth_tx_hairpin_queue_setup_t tx_hairpin_queue_setup;/**< Set up device TX hairpin queue. */ +hairpin_get_peer_ports_t hairpin_get_peer_ports; +/**< Get hairpin peer ports list. */ eth_hairpin_bind_t hairpin_bind;/**< Bind all hairpin TX queues of device to the peer port RX queues. */ eth_hairpin_unbind_t hairpin_unbind;
lib/librte_ethdev/rte_ethdev_version.map +1 -0
@@ -228,6 +228,7 @@ EXPERIMENTAL { # added in 20.11 rte_eth_hairpin_bind; + rte_eth_hairpin_get_peer_ports; rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v3 3/6] ethdev: add API to get hairpin peer ports list
Hi Bing,
Quoted 23 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, October 8, 2020 3:05 PM
Subject: [PATCH v3 3/6] ethdev: add API to get hairpin peer ports listAfter hairpin queues are configured, in general, the application will maintain the ports topology and even the queues configuration for hairpin. But sometimes it will not.
If there is no hot-plug, it is easy to bind and unbind hairpin among all the ports. The application can just connect or disconnect the hairpin egress ports to / from all the probed ingress ports. Then all the connections could be handled properly.
But with hot-plug / hot-unplug, one port could be probed and removed dynamically. With two ports hairpin, all the connections from and to this port should be handled after start(bind) or before stop(unbind). It is necessary to know the hairpin topology with this port.
This API will return the ports list with the actual peer ports number after configuration. Either peer RX or TX ports will be gotten with this function call.
Quoted 6 lines
Signed-off-by Bing Zhao <[email protected]>---
v3:
1. change the direction from bool to unsigned int type
2. add length to protect the array from getting corrupted
---
Thanks,
Ori
PATCH v3 4/6 ethdev: add APIs for hairpin queue operation
In reply to Bing ZhaoEvery hairpin queue pair should be configured properly and the connection between TX and RX queues should be established, before hairpin function works. In single port hairpin mode, the queues of each pair belong to the same device. It is easy to get the hardware and software information of each queue and configure the hairpin connection with such information. In two ports hairpin mode, it is not easy or inappropriate to access one queue's information from another device.
Since hairpin is configured per queue pair, three new APIs are introduced and they are internal for the PMD using.
The peer update API helps to pass one queue's information to the peer queue and get the peer's information back for the next step. The peer bind API configures the current queue with the peer's information. For each hairpin queue pair, this API may need to be called twice to configure the TX, RX queues separately. The peer unbind API resets the current queue configuration and state to disconnect it from the peer queue. Also, it may need to be called twice to disconnect TX, RX queues from each other.
Some parameter of the above APIs might not be mandatory, and it depends on the PMD implementation.
The structure of rte_hairpin_peer_info is only a declaration and the actual members will be defined in each PMD when being used.
---
v3: change the direction from bool to unsigned int type
--- lib/librte_ethdev/rte_ethdev.c | 55 +++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 102 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 3 files changed, 160 insertions(+)
lib/librte_ethdev/rte_ethdev.c +55 -0
@@ -5459,6 +5459,61 @@ enum rte_eth_switch_domain_state {return 0 ; } +int +rte_eth_hairpin_queue_peer_update (uint16_t peer_port,uint16_t peer_queue, +struct rte_hairpin_peer_info *cur_info, +struct rte_hairpin_peer_info *peer_info, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +/* Current queue information is not mandatory. */ +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[peer_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_update, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_update)(dev, peer_queue, + cur_info, peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_bind (uint16_t cur_port,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_bind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_bind)(dev, cur_queue, + peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_unbind (uint16_t cur_port,uint16_t cur_queue, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_unbind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_unbind)(dev, cur_queue, + direction); +} +RTE_LOG_REGISTER (rte_eth_dev_logtype, lib.ethdev,INFO );RTE_INIT (ethdev_init_telemetry)
lib/librte_ethdev/rte_ethdev_driver.h +102 -0
126 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -251,6 +251,9 @@ INTERNAL { rte_eth_devargs_parse; rte_eth_dma_zone_free; rte_eth_dma_zone_reserve; + rte_eth_hairpin_queue_peer_bind; + rte_eth_hairpin_queue_peer_unbind; + rte_eth_hairpin_queue_peer_update; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; rte_flow_expand_rss;
Signature · 1 line
1.8.3.1
PATCH v3 5/6 app/testpmd: change hairpin queues setup
In reply to Bing ZhaoA new parameter hairpin-mode is introduced to the testpmd command line. Bitmask value is used to provide more flexible configuration. This parameter should be used when hairpinq is specified in the command line.
Bit 0 in the LSB indicates the hairpin will use the loop mode. The previous port RX queue will be connected to the current port TX queue.
Bit 1 in the LSB indicates the hairpin will use pair port mode. The even index port will be paired with the next odd index port. If the total number of probed port is odd, then the last one will be paired to itself.
If this byte is zero, then each port will be paired to itself. Bit 0 takes a higher priority in the checking.
Bit 4 in the second bytes indicate if the hairpin will use explicit TX flow mode.
e.g. in the command line, "--hairpinq=2 --hairpin-mode=0x11"
If not set, default value zero will be used and the behavior will try to get align with the previous single port mode. If the ports belong to different vendors' NICs, it is suggested to use the self hairpin mode only.
Since hairpin configures the hardware resources, the port mask of packets forwarding engine will not be used here.
---
v2: move the hairpin bind/unbind into start/stop to support hot-plug
and hot-unplug
--- app/test-pmd/parameters.c | 15 ++++++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++++++++++++++++++++++++++-- app/test-pmd/testpmd.h | 2 + 3 files changed, 138 insertions(+), 4 deletions(-)
app/test-pmd/parameters.c +15 -0
@@ -221,6 +221,9 @@ "enabled\n");printf (" --record-core-cycles: enable measurement of CPU cycles.\n" );printf (" --record-burst-stats: enable display of RX and TX bursts.\n" ); +printf (" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n " +" 0x10 - explicit tx rule, 0x02 - hairpin ports paired\n" +" 0x01 - hairpin ports loop, 0x00 - hairpin port self\n" ); }#ifdef RTE_LIBRTE_CMDLINE
@@ -644,6 +647,7 @@ { "rxd", 1, 0, 0 }, { "txd", 1, 0, 0 }, { "hairpinq", 1, 0, 0 }, + { "hairpin-mode", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 },
@@ -1111,6 +1115,17 @@rte_exit (EXIT_FAILURE ,"Either rx or tx queues should " "be non-zero\n" ); } +if (!strcmp (lgopts[opt_idx].name,"hairpin-mode" )) { +char *end =NULL ; +unsigned int n; + + errno =0 ; + n =strtoul (optarg, &end,0 ); +if (errno !=0 || end == optarg) +rte_exit (EXIT_FAILURE ,"hairpin mode invalid\n" ); +else + hairpin_mode = (uint16_t )n; + }if (!strcmp (lgopts[opt_idx].name,"burst" )) { n =atoi (optarg);if (n ==0 ) {
app/test-pmd/testpmd.c +121 -4
195 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -398,6 +398,8 @@ struct queue_stats_mappings {extern uint16_t stats_period; +extern uint16_t hairpin_mode; +#ifdef RTE_LIBRTE_LATENCY_STATS extern uint8_t latencystats_enabled;extern lcoreid_t latencystats_lcore_id;
Signature · 1 line
1.8.3.1
PATCH v3 6/6 doc: update for two ports hairpin mode
In reply to Bing ZhaoIn the release notes, 2 ports hairpin mode feature is added.
In rte flow part, one suggestion is added to mention that metadata could be used to connect the hairpin RX and TX flows if the hairpin is working in explicit TX flow rule mode.
In the testpmd command line, the new parameter to set hairpin working mode is described.
--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++ 3 files changed, 19 insertions(+)
doc/guides/prog_guide/rte_flow.rst +3 -0
@@ -2592,6 +2592,9 @@ set, unpredictable value will be seen depending on driver implementation. For loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to the other path depending on HW capability. +In hairpin case with TX explicit flow mode, metadata could (not mandatory) be +used to connect the RX and TX flows if it can be propagated from RX to TX path. + .. _table_rte_flow_action_set_meta: .. table:: SET_META
doc/guides/rel_notes/release_20_11.rst +8 -0
@@ -109,6 +109,10 @@ New Features * Extern objects and functions can be plugged into the pipeline. * Transaction-oriented table updates. +* **Updated the ethdev library to support hairpin between two ports.** + + New APIs are introduced to support binding / unbinding 2 ports hairpin. + Hairpin TX part flow rules can be inserted explicitly. Removed Items -------------
@@ -240,6 +244,10 @@ ABI Changes * ``ethdev`` internal functions are marked with ``__rte_internal`` tag. + * ``struct rte_eth_hairpin_conf`` has two new members: + + * ``uint32_t tx_explicit:1;`` + * ``uint32_t manual_bind:1;`` Known Issues ------------
doc/guides/testpmd_app_ug/run_app.rst +8 -0
@@ -497,3 +497,11 @@ The command line options are: * ``--record-burst-stats`` Enable display of RX and TX burst stats. + +* ``--hairpin-mode=0xXX`` + + Set the hairpin port mode with bitmask, only valid when hairpin queues number is set. + bit 4 - explicit TX flow rule + bit 1 - two hairpin ports paired + bit 0 - two hairpin ports loop + The default value is 0. Hairpin will use single port mode and implicit TX flow mode.
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v3 6/6] doc: update for two ports hairpin mode
08/10/2020 14:05, Bing Zhao:
Quoted 9 lines
In the release notes, 2 ports hairpin mode feature is added.
In rte flow part, one suggestion is added to mention that metadata could be used to connect the hairpin RX and TX flows if the hairpin is working in explicit TX flow rule mode.
In the testpmd command line, the new parameter to set hairpin working mode is described.
Quoted 7 lines
Signed-off-by Bing Zhao <[email protected]>Acked-by Ori Kam <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++ 3 files changed, 19 insertions(+)
Please squash doc changes in related code changes commits, so both are atomic. Thanks
Re: [dpdk-dev] [PATCH v3 6/6] doc: update for two ports hairpin mode
Hi Thomas,
Quoted 34 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 13, 2020 5:31 AM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 6/6] doc: update for two ports hairpin modeExternal email: Use caution opening links or attachments
08/10/2020 14:05, Bing Zhao:
Quoted 4 lines
In the release notes, 2 ports hairpin mode feature is added.
In rte flow part, one suggestion is added to mention that metadata could be used to connect the hairpin RX and TX flows if the
hairpin is
Quoted 3 lines
working in explicit TX flow rule mode.
In the testpmd command line, the new parameter to set hairpin
working
Quoted 9 lines
mode is described.
Signed-off-by Bing Zhao <[email protected]>Acked-by Ori Kam <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++ 3 files changed, 19 insertions(+)
Quoted 2 lines
Please squash doc changes in related code changes commits, so both are atomic. Thanks
OK, I will rebase and squash them into other commits. So there is no need to care about the check patches warning of the headline prefix, am I right?
Quoted 2 lines
Thanks a lot
BR. Bing
Re: [dpdk-dev] [PATCH v3 6/6] doc: update for two ports hairpin mode
13/10/2020 03:13, Bing Zhao:
Quoted 21 lines
From: Thomas Monjalon <[email protected]>
Quoted 20 lines
08/10/2020 14:05, Bing Zhao:
Quoted 4 lines
In the release notes, 2 ports hairpin mode feature is added.
In rte flow part, one suggestion is added to mention that metadata could be used to connect the hairpin RX and TX flows if the
hairpin is
Quoted 3 lines
working in explicit TX flow rule mode.
In the testpmd command line, the new parameter to set hairpin
working
Quoted 9 lines
mode is described.
Signed-off-by Bing Zhao <[email protected]>Acked-by Ori Kam <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++ 3 files changed, 19 insertions(+)
Quoted 6 lines
Quoted 2 lines
Please squash doc changes in related code changes commits, so both are atomic. Thanks
OK, I will rebase and squash them into other commits. So there is no need to care about the check patches warning of the headline prefix, am I right?
Right
We should improve this script to be less strict.
Re: [dpdk-dev] [PATCH v3 6/6] doc: update for two ports hairpin mode
Hi Thomas,
Quoted 41 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 13, 2020 2:37 PM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 6/6] doc: update for two ports hairpin modeExternal email: Use caution opening links or attachments
13/10/2020 03:13, Bing Zhao:
Quoted 5 lines
From: Thomas Monjalon <[email protected]>
Quoted 4 lines
08/10/2020 14:05, Bing Zhao:
Quoted 3 lines
In the release notes, 2 ports hairpin mode feature is added.
In rte flow part, one suggestion is added to mention that
metadata
Quoted 16 lines
Quoted 16 lines
Quoted 1 line
could be used to connect the hairpin RX and TX flows if the
hairpin is
Quoted 3 lines
working in explicit TX flow rule mode.
In the testpmd command line, the new parameter to set hairpin
working
Quoted 9 lines
mode is described.
Signed-off-by Bing Zhao <[email protected]>Acked-by Ori Kam <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 8 ++++++++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++++++++ 3 files changed, 19 insertions(+)Quoted 1 line
Quoted 1 line
Please squash doc changes in related code changes commits, so
both
Quoted 2 lines
Quoted 1 line
are atomic. Thanks
Quoted 9 lines
Quoted 1 line
OK, I will rebase and squash them into other commits. So there is
no
Quoted 1 line
need to care about the check patches warning of the headline
prefix,
Quoted 1 line
am I right?
Right
We should improve this script to be less strict.
I see.
So many thanks
v4 cover introduce support for hairpin between two ports
In reply to Bing ZhaoThe patches contain the following changes:
1. new APIs to bind and unbind hairpin ports in manual binding mode.
2. new API to get the hairpin peer ports list.
3. new internal APIs for PMD to pass the queue information and configure the queue pair.
4. new attribute members in the hairpin queue configuraiton structure to specify the binding mode and enable explicit TX flow mode.
5. Testpmd support to configure the hairpin modes for two ports hairpin verification.
6. documents update.
---
v4:
1. squash documents update into patch
2. add more description of the hairpin conf attributes
v3:
1. add length to protect the pointer to the array from getting corrupted
2. change the direction from bool to unsigned int
v2:
1. add documents update
2. remove all peer ports logic from rte API
3. conf structure optimizing
4. new API to get the peer ports and testpmd change to support hot-plug / unplug case
---
Bing Zhao (5):
ethdev: add hairpin bind and unbind APIs
ethdev: add new attributes to hairpin config
ethdev: add API to get hairpin peer ports list
ethdev: add APIs for hairpin queue operation
app/testpmd: change hairpin queues setup
app/test-pmd/parameters.c | 15 +++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++- app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 3 + doc/guides/rel_notes/release_20_11.rst | 11 ++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++ lib/librte_ethdev/rte_ethdev.c | 133 +++++++++++++++++++++- lib/librte_ethdev/rte_ethdev.h | 107 +++++++++++++++++- lib/librte_ethdev/rte_ethdev_driver.h | 187 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 6 + 10 files changed, 588 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v4 1/5 ethdev: add hairpin bind and unbind APIs
In single port hairpin mode, all the hairpin TX and RX queues belong to the same device. After the queues are set up properly, there is no other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized already for the binding process.
But in two ports hairpin mode, there will be some cross-dependences between two different ports. Usually, the ports will be initialized serially by the main thread but not in parallel. The earlier port will not be able to enable the bind if the following peer port is not yet configured with HW resources. What's more, if one port is detached / attached dynamically, it would introduce more trouble for the hairpin binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set up. Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the rte_eth_hairpin_bind() API can be called to bind the all TX queues of the egress port to the RX queues of the peer port. Then the connection between the egress and ingress ports pair will be established.
The rte_eth_hairpin_unbind() API could be used to disconnect the egress and the peer ingress ports. This should only be called before the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken into consideration, especially in the hot unplug case. mode is described.
---
v4: squash release notes update
v2: remove the all peer ports logic from rte API
--- doc/guides/rel_notes/release_20_11.rst | 4 +++ lib/librte_ethdev/rte_ethdev.c | 46 ++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 51 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 ++ 5 files changed, 155 insertions(+)
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -60,6 +60,10 @@ New Features Added the FEC API which provides functions for query FEC capabilities and current FEC mode from device. Also, API for configuring FEC mode is also provided. +* **Updated the ethdev library to support hairpin between two ports.** + + New APIs are introduced to support binding / unbinding 2 ports hairpin. + * **Updated Broadcom bnxt driver.** Updated the Broadcom bnxt driver with new features and improvements, including:
lib/librte_ethdev/rte_ethdev.c +46 -0
52 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +51 -0
57 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_driver.h +52 -0
64 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +2 -0
@@ -227,6 +227,8 @@ EXPERIMENTAL { rte_tm_wred_profile_delete; # added in 20.11 + rte_eth_hairpin_bind; + rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; rte_eth_fec_get_capability;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v4 1/5] ethdev: add hairpin bind and unbind APIs
Sorry I messed up versions and did a review on the v3, which is still relevant for v4. Please check:
http://mails.dpdk.org/archives/dev/2020-October/186614.html
Re: [dpdk-dev] [PATCH v4 1/5] ethdev: add hairpin bind and unbind APIs
Hi Thomas,
All your comments are confirmed and addressed.
Thanks
Quoted 23 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 14, 2020 10:43 PM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4 1/5] ethdev: add hairpin bind and unbind APIsExternal email: Use caution opening links or attachments
Sorry I messed up versions and did a review on the v3, which is still relevant for v4. Please check:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmai
ls.dpdk.org%2Farchives%2Fdev%2F2020- October%2F186614.html&data=02%7C01%7Cbingz%40nvidia.com%7C88b908 cfd5f14532065908d8704f9e8c%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C 0%7C637382834554491809&sdata=2Dm0m5vty8qm%2BgeDEBQUFi3JR7OjgUa8Y d%2FxQheqgOA%3D&reserved=0
PATCH v4 2/5 ethdev: add new attributes to hairpin config
In reply to Bing ZhaoTo support two ports hairpin mode and keep the backward compatibility for the application, two new attribute members of the hairpin queue configuration structure will be added.
tx_explicit means if the application itself will insert the TX part flow rules. If not set, PMD will insert the rules implicitly. manual_bind means if the hairpin TX queue and peer RX queue will be bound automatically during the device start stage.
Different TX and RX queue pairs could have different values, but it is highly recommended that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD drivers.
In the single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means that no bind API needs to be called and no TX flow rules need to be inserted manually by the application.
---
v4: squash document update and more info for the two new attributes
v2: optimize the structure and remove unused macros
--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 6 ++++++ lib/librte_ethdev/rte_ethdev.c | 8 ++++---- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++++++++++++++- 4 files changed, 39 insertions(+), 5 deletions(-)
doc/guides/prog_guide/rte_flow.rst +3 -0
@@ -2592,6 +2592,9 @@ set, unpredictable value will be seen depending on driver implementation. For loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to the other path depending on HW capability. +In hairpin case with TX explicit flow mode, metadata could (not mandatory) be +used to connect the RX and TX flows if it can be propagated from RX to TX path. + .. _table_rte_flow_action_set_meta: .. table:: SET_META
doc/guides/rel_notes/release_20_11.rst +6 -0
@@ -63,6 +63,7 @@ New Features * **Updated the ethdev library to support hairpin between two ports.** New APIs are introduced to support binding / unbinding 2 ports hairpin. + Hairpin TX part flow rules can be inserted explicitly. * **Updated Broadcom bnxt driver.**
@@ -318,6 +319,11 @@ ABI Changes * ``ethdev`` internal functions are marked with ``__rte_internal`` tag. + * ``struct rte_eth_hairpin_conf`` has two new members: + + * ``uint32_t tx_explicit:1;`` + * ``uint32_t manual_bind:1;`` + Known Issues ------------
lib/librte_ethdev/rte_ethdev.c +4 -4
@@ -1954,13 +1954,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_rx_2_tx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Rx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_rx_2_tx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Rx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
@@ -2125,13 +2125,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_tx_2_rx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Tx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_tx_2_rx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Tx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
lib/librte_ethdev/rte_ethdev.h +26 -1
@@ -1045,7 +1045,32 @@ struct rte_eth_hairpin_peer {* A structure used to configure hairpin binding. */ struct rte_eth_hairpin_conf { -uint16_t peer_count;/**< The number of peers. */ +uint32_t peer_count:16 ;/**< The number of peers. */ + +/** +* Explicit TX flow rule mode. One hairpin pair of queues should have +* the same attribute. The actual support depends on the PMD. +* +* - When set, the user should be responsible for inserting the hairpin +* TX part flows and removing them. +* - When clear, the PMD will try to handle the TX part of the flows, +* e.g., by splitting one flow into two parts. +*/ +uint32_t tx_explicit:1 ; + +/** +* Manually bind hairpin queues. One hairpin pair of queues should have +* the same attribute. The actual support depends on the PMD. +* +* - When set, to enable hairpin, the user should call the hairpin bind +* API after all the queues are set up properly and the ports are +* started. Also, the hairpin unbind API should be called accordingly +* before stopping a port that with hairpin configured. +* - When clear, the PMD will try to enable the hairpin with the queues +* configured automatically during port start. +*/ +uint32_t manual_bind:1 ; +uint32_t reserved:14 ;/**< Reserved bits. */ struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; };
Signature · 1 line
1.8.3.1
PATCH v4 3/5 ethdev: add API to get hairpin peer ports list
In reply to Bing ZhaoAfter hairpin queues are configured, in general, the application will maintain the ports topology and even the queues configuration for the hairpin. But sometimes it will not.
If there is no hot-plug, it is easy to bind and unbind hairpin among all the ports. The application can just connect or disconnect the hairpin egress ports to/from all the probed ingress ports. Then all the connections could be handled properly.
But with hot-plug / hot-unplug, one port could be probed and removed dynamically. With two ports hairpin, all the connections from and to this port should be handled after start(bind) or before stop(unbind). It is necessary to know the hairpin topology with this port.
This API will return the ports list with the actual peer ports number after configuration. Either peer RX or TX ports will be gotten with this function call.
---
v4: add release notes update
v3:
1. change the direction from bool to unsigned int type
2. add length to protect the array from getting corrupted
--- doc/guides/rel_notes/release_20_11.rst | 1 + lib/librte_ethdev/rte_ethdev.c | 24 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 29 ++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 33 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 5 files changed, 88 insertions(+)
doc/guides/rel_notes/release_20_11.rst +1 -0
@@ -64,6 +64,7 @@ New Features New APIs are introduced to support binding / unbinding 2 ports hairpin. Hairpin TX part flow rules can be inserted explicitly. + New API is added to get the hairpin peer ports list. * **Updated Broadcom bnxt driver.**
lib/librte_ethdev/rte_ethdev.c +24 -0
@@ -2208,6 +2208,30 @@ struct rte_eth_dev *return ret; } +int +rte_eth_hairpin_get_peer_ports (uint16_t cur_port,uint16_t *peer_ports, +size_t len,uint32_t direction) +{ +struct rte_eth_dev *dev; +int ret; + +if (!peer_ports || !len) +return -EINVAL ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (cur_port, -EINVAL ); + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_get_peer_ports, + -ENOTSUP ); + + ret = (*dev->dev_ops->hairpin_get_peer_ports)(dev, peer_ports, + len, direction); +if (ret <0 ) +RTE_ETHDEV_LOG (ERR ,"Failed to get %d hairpin peer %s ports" , + cur_port, direction ?"RX" :"TX" ); + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)
lib/librte_ethdev/rte_ethdev.h +29 -0
@@ -2186,6 +2186,35 @@ int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,* @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice * +* Get all the hairpin peer RX / TX ports of the current port. +* The caller should ensure that the array is large enough to save the ports +* list. +* +* @param cur_port +* The current port identifier of the Ethernet device. +* @param peer_ports +* Pointer to the array to store the peer ports list. +* @param len +* Length of the array to store the port identifiers. +* @param direction +* Current port to peer port direction +* positive - current used as TX to get all peer RX ports. +* zero - current used as RX to get all peer TX ports. +* +* @return +* - (0 or positive) actual peer ports number. +* - (-EINVAL) if bad parameter. +* - (-ENOTSUP) if hardware doesn't support. +* - Others detailed errors from PMD drivers. +*/ +__rte_experimental +int rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_ports, +size_t len,uint32_t direction); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* * Bind all hairpin TX queues of one port to the RX queues of the peer port. * It is only allowed to call this API after all hairpin queues are configured * properly and the devices of TX and peer RX are in started state.
lib/librte_ethdev/rte_ethdev_driver.h +33 -0
@@ -657,6 +657,37 @@ typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,/** * @internal +* Get all hairpin TX/RX peer ports of the current device, if any. +* +* @param dev +* ethdev handle of port. +* @param peer_ports +* array to save the ports list. +* @param len +* array length. +* @param direction +* value to decide the current to peer direction +* positive - used as TX to get all peer RX ports. +* zero - used as RX to get all peer TX ports. +* +* @return +* Negative errno value on error, 0 or positive on success. +* +* @retval 0 +* Success, no peer ports. +* @retval >0 +* Actual number of the peer ports. +* @retval -ENOTSUP +* Get peer ports API is not supported. +* @retval -EINVAL +* One of the parameters is invalid. +*/ +typedef int (*hairpin_get_peer_ports_t )(struct rte_eth_dev *dev, +uint16_t *peer_ports,size_t len, +uint32_t direction); + +/** +* @internal * Bind all hairpin TX queues of one port to the RX queues of the peer port. * * @param dev
@@ -849,6 +880,8 @@ struct eth_dev_ops {/**< Get Forward Error Correction(FEC) mode. */ eth_fec_set_t fec_set;/**< Set Forward Error Correction(FEC) mode. */ +hairpin_get_peer_ports_t hairpin_get_peer_ports; +/**< Get hairpin peer ports list. */ eth_hairpin_bind_t hairpin_bind;/**< Bind all hairpin TX queues of device to the peer port RX queues. */ eth_hairpin_unbind_t hairpin_unbind;
lib/librte_ethdev/rte_ethdev_version.map +1 -0
@@ -228,6 +228,7 @@ EXPERIMENTAL { # added in 20.11 rte_eth_hairpin_bind; + rte_eth_hairpin_get_peer_ports; rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v4 3/5] ethdev: add API to get hairpin peer ports list
13/10/2020 18:19, Bing Zhao:
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +1
-0@@ -2208,6 +2208,30 @@ struct rte_eth_dev *return ret; } +int
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2221
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c +10
-0+rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_ports, + size_t len, uint32_t direction) +{ + struct rte_eth_dev *dev; +int ret; + +if (!peer_ports || !len) +return -EINVAL ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (cur_port, -EINVAL );
should be -ENODEV
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2230
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.c +9
-0+ dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_get_peer_ports, + -ENOTSUP ); + + ret = (*dev->dev_ops->hairpin_get_peer_ports)(dev, peer_ports, + len, direction); +if (ret <0 ) +RTE_ETHDEV_LOG (ERR ,"Failed to get %d hairpin peer %s ports" , + cur_port, direction ?"RX" :"TX" );
Missing \n
Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +3
-0+ +return ret; +}
lib/librte_ethdev/rte_ethdev.h int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id, · line 2194
Quoted 9 lines
lib/librte_ethdev/rte_ethdev.h +6
-0* @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice * +* Get all the hairpin peer RX / TX ports of the current port. +* The caller should ensure that the array is large enough to save the ports +* list. +* +* @param cur_port +* The current port identifier of the Ethernet device.
Why current? In general we use "port_id".
Quoted 5 lines
+ * @param
peer_ports
+ * Pointer to the array to store the peer ports list.
+ * @param len
+ * Length of the array to store the port identifiers.
+ * @param direction
Quoted 9 lines
+ * Current port to peer port direction + * positive - current used as TX to get all peer RX ports. + * zero - current used as RX to get all peer TX ports. + * + * @return + * - (0 or positive) actual peer ports number. + * - (-EINVAL) if bad parameter. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.
Please add ENODEV
Quoted 4 lines
+ */
lib/librte_ethdev/rte_ethdev.h +3
-0+__rte_experimental +int rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t *peer_ports, +size_t len,uint32_t direction);
Re: [dpdk-dev] [PATCH v4 3/5] ethdev: add API to get hairpin peer ports list
Hi Thomas,
Quoted 24 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 14, 2020 11:02 PM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4 3/5] ethdev: add API to get hairpin peer ports listExternal email: Use caution opening links or attachments
13/10/2020 18:19, Bing Zhao:
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2212
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +2
-0@@ -2208,6 +2208,30 @@ struct rte_eth_dev *return ret; } +int +rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t
*peer_ports,
Quoted 10 lines
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2221
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +8
-0+ size_t len, uint32_t direction) { +struct rte_eth_dev *dev; +int ret; + +if (!peer_ports || !len) +return -EINVAL ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (cur_port, -EINVAL );should be
-ENODEV
Fixed
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev *
Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +5
-0+ dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops- hairpin_get_peer_ports, + -ENOTSUP ); + + ret = (*dev->dev_ops->hairpin_get_peer_ports)(dev,
peer_ports,
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2227
Quoted 1 line
lib/librte_ethdev/rte_ethdev.c +1
-0+ len,direction);
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2229
Quoted 2 lines
lib/librte_ethdev/rte_ethdev.c +2
-0+if (ret <0 ) + RTE_ETHDEV_LOG(ERR, "Failed to get %d hairpinpeer %s ports",
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2230
Quoted 1 line
lib/librte_ethdev/rte_ethdev.c +1
-0+ cur_port, direction ? "RX" : "TX");Missing \n
Thanks, done.
Quoted 12 lines
lib/librte_ethdev/rte_ethdev.h
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.c +3
-0+ +return ret; +}lib/librte_ethdev/rte_ethdev.h +0
-0* @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
Quoted 3 lines
*
+ * Get all the hairpin peer RX / TX ports of the current port.
+ * The caller should ensure that the array is large enough to
Quoted 8 lines
save
Quoted 5 lines
+ the ports
+ * list.
+ *
+ * @paramcur_port
+ * The current port identifier of the Ethernet device.Why current? In general we use "
port_id".
Changed to port_id
Quoted 16 lines
Quoted 6 lines
+ * @param
peer_ports
+ * Pointer to the array to store the peer ports list.
+ * @param len
+ * Length of the array to store the port identifiers.
+ * @param directionQuoted 9 lines
+ * Current port to peer port direction + * positive - current used as TX to get all peer RX ports. + * zero - current used as RX to get all peer TX ports. + * + * @return + * - (0 or positive) actual peer ports number. + * - (-EINVAL) if bad parameter. + * - (-ENOTSUP) if hardware doesn't support. + * - Others detailed errors from PMD drivers.
Quoted 1 line
Please add ENODEV
Done.
Quoted 8 lines
lib/librte_ethdev/rte_ethdev.h
Quoted 4 lines
+ */
lib/librte_ethdev/rte_ethdev.h +2
-0+__rte_experimental +int rte_eth_hairpin_get_peer_ports(uint16_t cur_port, uint16_t
*peer_ports,Quoted 1 line
+
size_tlen,uint32_tdirection);
Thanks a lot~
PATCH v4 4/5 ethdev: add APIs for hairpin queue operation
In reply to Bing ZhaoEvery hairpin queue pair should be configured properly and the connection between TX and RX queues should be established, before hairpin function works. In single port hairpin mode, the queues of each pair belong to the same device. It is easy to get the hardware and software information of each queue and configure the hairpin connection with such information. In two ports hairpin mode, it is not easy or inappropriate to access one queue's information from another device.
Since hairpin is configured per queue pair, three new APIs are introduced and they are internal for the PMD using.
The peer update API helps to pass one queue's information to the peer queue and get the peer's information back for the next step. The peer bind API configures the current queue with the peer's information. For each hairpin queue pair, this API may need to be called twice to configure the TX, RX queues separately. The peer unbind API resets the current queue configuration and state to disconnect it from the peer queue. Also, it may need to be called twice to disconnect TX, RX queues from each other.
Some parameter of the above APIs might not be mandatory, and it depends on the PMD implementation.
The structure of rte_hairpin_peer_info is only a declaration and the actual members will be defined in each PMD when being used.
---
v3: change the direction from bool to unsigned int type
--- lib/librte_ethdev/rte_ethdev.c | 55 +++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 102 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 3 files changed, 160 insertions(+)
lib/librte_ethdev/rte_ethdev.c +55 -0
@@ -5564,6 +5564,61 @@ enum rte_eth_switch_domain_state {return 0 ; } +int +rte_eth_hairpin_queue_peer_update (uint16_t peer_port,uint16_t peer_queue, +struct rte_hairpin_peer_info *cur_info, +struct rte_hairpin_peer_info *peer_info, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +/* Current queue information is not mandatory. */ +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[peer_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_update, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_update)(dev, peer_queue, + cur_info, peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_bind (uint16_t cur_port,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_bind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_bind)(dev, cur_queue, + peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_unbind (uint16_t cur_port,uint16_t cur_queue, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_unbind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_unbind)(dev, cur_queue, + direction); +} +RTE_LOG_REGISTER (rte_eth_dev_logtype, lib.ethdev,INFO );RTE_INIT (ethdev_init_telemetry)
lib/librte_ethdev/rte_ethdev_driver.h +102 -0
126 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -254,6 +254,9 @@ INTERNAL { rte_eth_devargs_parse; rte_eth_dma_zone_free; rte_eth_dma_zone_reserve; + rte_eth_hairpin_queue_peer_bind; + rte_eth_hairpin_queue_peer_unbind; + rte_eth_hairpin_queue_peer_update; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; };
Signature · 1 line
1.8.3.1
PATCH v4 5/5 app/testpmd: change hairpin queues setup
In reply to Bing ZhaoA new parameter hairpin-mode is introduced to the testpmd command line. Bitmask value is used to provide a more flexible configuration. This parameter should be used when hairpinq is specified in the command line.
Bit 0 in the LSB indicates the hairpin will use the loop mode. The previous port RX queue will be connected to the current port TX queue.
Bit 1 in the LSB indicates the hairpin will use pair port mode. The even index port will be paired with the next odd index port. If the total number of the probed ports is odd, then the last one will be paired to itself.
If this byte is zero, then each port will be paired to itself. Bit 0 takes a higher priority in the checking.
Bit 4 in the second bytes indicate if the hairpin will use explicit TX flow mode.
e.g. in the command line, "--hairpinq=2 --hairpin-mode=0x11"
If not set, default value zero will be used and the behavior will try to get aligned with the previous single port mode. If the ports belong to different vendors' NICs, it is suggested to use the self hairpin mode only.
Since hairpin configures the hardware resources, the port mask of packets forwarding engine will not be used here.
---
v4: squash testpmd guide update
v2: move the hairpin bind/unbind into start/stop to support hot-plug
and hot-unplug
--- app/test-pmd/parameters.c | 15 ++++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++++++++++++++-- app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/run_app.rst | 8 +++ 4 files changed, 146 insertions(+), 4 deletions(-)
app/test-pmd/parameters.c +15 -0
@@ -222,6 +222,9 @@ "enabled\n");printf (" --record-core-cycles: enable measurement of CPU cycles.\n" );printf (" --record-burst-stats: enable display of RX and TX bursts.\n" ); +printf (" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n " +" 0x10 - explicit tx rule, 0x02 - hairpin ports paired\n" +" 0x01 - hairpin ports loop, 0x00 - hairpin port self\n" ); }#ifdef RTE_LIBRTE_CMDLINE
@@ -645,6 +648,7 @@ { "rxd", 1, 0, 0 }, { "txd", 1, 0, 0 }, { "hairpinq", 1, 0, 0 }, + { "hairpin-mode", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 },
@@ -1113,6 +1117,17 @@rte_exit (EXIT_FAILURE ,"Either rx or tx queues should " "be non-zero\n" ); } +if (!strcmp (lgopts[opt_idx].name,"hairpin-mode" )) { +char *end =NULL ; +unsigned int n; + + errno =0 ; + n =strtoul (optarg, &end,0 ); +if (errno !=0 || end == optarg) +rte_exit (EXIT_FAILURE ,"hairpin mode invalid\n" ); +else + hairpin_mode = (uint16_t )n; + }if (!strcmp (lgopts[opt_idx].name,"burst" )) { n =atoi (optarg);if (n ==0 ) {
app/test-pmd/testpmd.c +121 -4
195 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -398,6 +398,8 @@ struct queue_stats_mappings {extern uint16_t stats_period; +extern uint16_t hairpin_mode; +#ifdef RTE_LIBRTE_LATENCY_STATS extern uint8_t latencystats_enabled;extern lcoreid_t latencystats_lcore_id;
doc/guides/testpmd_app_ug/run_app.rst +8 -0
@@ -503,3 +503,11 @@ The command line options are: * ``--record-burst-stats`` Enable display of RX and TX burst stats. + +* ``--hairpin-mode=0xXX`` + + Set the hairpin port mode with bitmask, only valid when hairpin queues number is set. + bit 4 - explicit TX flow rule + bit 1 - two hairpin ports paired + bit 0 - two hairpin ports loop + The default value is 0. Hairpin will use single port mode and implicit TX flow mode.
Signature · 1 line
1.8.3.1
v5 cover introduce support for hairpin between two ports
In reply to Bing ZhaoThe patches contain the following changes:
1. new APIs to bind and unbind hairpin ports in manual binding mode.
2. new API to get the hairpin peer ports list.
3. new internal APIs for PMD to pass the queue information and configure the queue pair.
4. new attribute members in the hairpin queue configuraiton structure to specify the binding mode and enable explicit TX flow mode.
5. Testpmd support to configure the hairpin modes for two ports hairpin verification.
6. documents update.
---
v5:
1. Change EINVAL to ENODEV if port id is invalid
2. Description fixes and other minor changes
v4:
1. squash documents update into patch
2. add more description of the hairpin conf attributes
v3:
1. add length to protect the pointer to the array from getting corrupted
2. change the direction from bool to unsigned int
v2:
1. add documents update
2. remove all peer ports logic from rte API
3. conf structure optimizing
4. new API to get the peer ports and testpmd change to support hot-plug / unplug case
---
Bing Zhao (5):
ethdev: add hairpin bind and unbind APIs
ethdev: add new attributes to hairpin config
ethdev: add API to get hairpin peer ports list
ethdev: add APIs for hairpin queue operation
app/testpmd: change hairpin queues setup
app/test-pmd/parameters.c | 15 +++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++- app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 3 + doc/guides/rel_notes/release_20_11.rst | 11 ++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++ lib/librte_ethdev/rte_ethdev.c | 133 +++++++++++++++++++++- lib/librte_ethdev/rte_ethdev.h | 109 +++++++++++++++++- lib/librte_ethdev/rte_ethdev_driver.h | 186 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 6 + 10 files changed, 589 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v5 1/5 ethdev: add hairpin bind and unbind APIs
In single port hairpin mode, all the hairpin TX and RX queues belong to the same device. After the queues are set up properly, there is no other dependency between the TX queue and its RX peer queue. The binding process that connected the TX and RX queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized already for the binding process.
But in two ports hairpin mode, there will be some cross-dependences between two different ports. Usually, the ports will be initialized serially by the main thread but not in parallel. The earlier port will not be able to enable the bind if the following peer port is not yet configured with HW resources. What's more, if one port is detached / attached dynamically, it would introduce more trouble for the hairpin binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin TX and RX peer queues will be set up. Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the rte_eth_hairpin_bind() API can be called to bind the all TX queues of the egress port to the RX queues of the peer port. Then the connection between the egress and ingress ports pair will be established.
The rte_eth_hairpin_unbind() API could be used to disconnect the egress and the peer ingress ports. This should only be called before the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken into consideration, especially in the hot unplug case. mode is described.
---
v5:
* Change EINVAL to ENODEV
* add newline character in the end of log line
* descriptions update
v4: squash release notes update
v2: remove the all peer ports logic from rte API
--- doc/guides/rel_notes/release_20_11.rst | 4 +++ lib/librte_ethdev/rte_ethdev.c | 46 ++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 52 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 ++ 5 files changed, 156 insertions(+)
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -67,6 +67,10 @@ New Features Added the FEC API which provides functions for query FEC capabilities and current FEC mode from device. Also, API for configuring FEC mode is also provided. +* **Updated the ethdev library to support hairpin between two ports.** + + New APIs are introduced to support binding / unbinding 2 ports hairpin. + * **Updated Broadcom bnxt driver.** Updated the Broadcom bnxt driver with new features and improvements, including:
lib/librte_ethdev/rte_ethdev.c +46 -0
52 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +52 -0
58 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_driver.h +52 -0
64 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +2 -0
@@ -227,6 +227,8 @@ EXPERIMENTAL { rte_tm_wred_profile_delete; # added in 20.11 + rte_eth_hairpin_bind; + rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; rte_eth_fec_get_capability;
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v5 1/5] ethdev: add hairpin bind and unbind APIs
15/10/2020 07:35, Bing Zhao:
Quoted 4 lines
v5:
* Change EINVAL to ENODEV
* add newline character in the end of log line
* descriptions update
It looks good.
More minor coding style comments below. With those,
Review
Quoted 1 line
(quoted diff) +1
-0+ if (ret)
Coding style recommends explicit comparison with == or !=
lib/librte_ethdev/rte_ethdev.c struct rte_eth_dev * · line 2233
Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +3
-0+RTE_ETHDEV_LOG (ERR ,"Failed to bind hairpin TX %d " +"to RX %d (%d - all ports)\n" , tx_port, + rx_port,RTE_MAX_ETHPORTS );
It is preferred not splitting the log lines,
or maybe only after a format specifier, so it can be grepped. Here the space after %d would be better on the next line.
In general Rx/Tx is preferred over the full capital RX/TX version.
Thanks
Re: [dpdk-dev] [PATCH v5 1/5] ethdev: add hairpin bind and unbind APIs
Hi Thomas,
Quoted 14 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, October 15, 2020 6:34 PM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v5 1/5] ethdev: add hairpin bind and unbind APIsExternal email: Use caution opening links or attachments
15/10/2020 07:35, Bing Zhao:
Quoted 8 lines
Quoted 4 lines
v5:
* Change EINVAL to ENODEV
* add newline character in the end of log line
* descriptions updateIt looks good.
More minor coding style comments below. With those,Acked-by Thomas Monjalon <[email protected]>
Thanks for the review and comments
Quoted 4 lines
Quoted 2 lines
+ if (ret)
Coding style recommends explicit comparison with == or !=
Done
Quoted 11 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ RTE_ETHDEV_LOG(ERR, "Failed to bind hairpin TX %d " + "to RX %d (%d - all ports)\n",
tx_port,Quoted 1 line
+
rx_port,RTE_MAX_ETHPORTS);It is preferred not splitting the log lines, or maybe only after a format specifier, so it can be grepped.
Here the space after %d would be better on the next line.In general Rx/Tx is preferred over the full capital RX/TX version.
Done
Quoted 3 lines
Thanks
BR. Bing
PATCH v5 2/5 ethdev: add new attributes to hairpin config
In reply to Bing ZhaoTo support two ports hairpin mode and keep the backward compatibility for the application, two new attribute members of the hairpin queue configuration structure will be added.
tx_explicit means if the application itself will insert the TX part flow rules. If not set, PMD will insert the rules implicitly. manual_bind means if the hairpin TX queue and peer RX queue will be bound automatically during the device start stage.
Different TX and RX queue pairs could have different values, but it is highly recommended that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD drivers.
In the single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means that no bind API needs to be called and no TX flow rules need to be inserted manually by the application.
---
v4: squash document update and more info for the two new attributes
v2: optimize the structure and remove unused macros
--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 6 ++++++ lib/librte_ethdev/rte_ethdev.c | 8 ++++---- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++++++++++++++- 4 files changed, 39 insertions(+), 5 deletions(-)
doc/guides/prog_guide/rte_flow.rst +3 -0
@@ -2592,6 +2592,9 @@ set, unpredictable value will be seen depending on driver implementation. For loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to the other path depending on HW capability. +In hairpin case with TX explicit flow mode, metadata could (not mandatory) be +used to connect the RX and TX flows if it can be propagated from RX to TX path. + .. _table_rte_flow_action_set_meta: .. table:: SET_META
doc/guides/rel_notes/release_20_11.rst +6 -0
@@ -70,6 +70,7 @@ New Features * **Updated the ethdev library to support hairpin between two ports.** New APIs are introduced to support binding / unbinding 2 ports hairpin. + Hairpin TX part flow rules can be inserted explicitly. * **Updated Broadcom bnxt driver.**
@@ -355,6 +356,11 @@ ABI Changes * ``ethdev`` internal functions are marked with ``__rte_internal`` tag. + * ``struct rte_eth_hairpin_conf`` has two new members: + + * ``uint32_t tx_explicit:1;`` + * ``uint32_t manual_bind:1;`` + Known Issues ------------
lib/librte_ethdev/rte_ethdev.c +4 -4
@@ -2004,13 +2004,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_rx_2_tx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Rx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_rx_2_tx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Rx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
@@ -2175,13 +2175,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_tx_2_rx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Tx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_tx_2_rx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Tx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
lib/librte_ethdev/rte_ethdev.h +26 -1
@@ -1045,7 +1045,32 @@ struct rte_eth_hairpin_peer {* A structure used to configure hairpin binding. */ struct rte_eth_hairpin_conf { -uint16_t peer_count;/**< The number of peers. */ +uint32_t peer_count:16 ;/**< The number of peers. */ + +/** +* Explicit TX flow rule mode. One hairpin pair of queues should have +* the same attribute. The actual support depends on the PMD. +* +* - When set, the user should be responsible for inserting the hairpin +* TX part flows and removing them. +* - When clear, the PMD will try to handle the TX part of the flows, +* e.g., by splitting one flow into two parts. +*/ +uint32_t tx_explicit:1 ; + +/** +* Manually bind hairpin queues. One hairpin pair of queues should have +* the same attribute. The actual support depends on the PMD. +* +* - When set, to enable hairpin, the user should call the hairpin bind +* API after all the queues are set up properly and the ports are +* started. Also, the hairpin unbind API should be called accordingly +* before stopping a port that with hairpin configured. +* - When clear, the PMD will try to enable the hairpin with the queues +* configured automatically during port start. +*/ +uint32_t manual_bind:1 ; +uint32_t reserved:14 ;/**< Reserved bits. */ struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; };
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v5 2/5] ethdev: add new attributes to hairpin config
15/10/2020 07:35, Bing Zhao:
Quoted 20 lines
To support two ports hairpin mode and keep the backward compatibility for the application, two new attribute members of the hairpin queue configuration structure will be added.
tx_explicitmeans if the application itself will insert the TX part flow rules. If not set, PMD will insert the rules implicitly.manual_bindmeans if the hairpin TX queue and peer RX queue will be bound automatically during the device start stage.Different TX and RX queue pairs could have different values, but it is highly recommended that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD drivers.
In the single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means that no bind API needs to be called and no TX flow rules need to be inserted manually by the application.
Quoted 6 lines
Signed-off-by Bing Zhao <[email protected]>Acked-by Ori Kam <[email protected]>---
v4: squash document update and more info for the two new attributes
v2: optimize the structure and remove unused macros
---
Minor comments below.
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer { · line 1052
Quoted 7 lines
struct
rte_eth_hairpin_conf{lib/librte_ethdev/rte_ethdev.h +5
-1-uint16_t peer_count;/**< The number of peers. */ + uint32_t peer_count:16; /**< The number of peers. */ + +/** +* Explicit TX flow rule mode. One hairpin pair of queues should have +* the same attribute. The actual support depends on the PMD.
The second sentence should be on a separate line.
About the third sentence, implementation is always PMD-specific. PMD will reject the not supported conf, as usual.
I think this comment is not needed in the API description.
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer { · line 1063
Quoted 11 lines
lib/librte_ethdev/rte_ethdev.h +11
-0+* +* - When set, the user should be responsible for inserting the hairpin +* TX part flows and removing them. +* - When clear, the PMD will try to handle the TX part of the flows, +* e.g., by splitting one flow into two parts. +*/ + uint32_t tx_explicit:1; + +/** +* Manually bind hairpin queues. One hairpin pair of queues should have +* the same attribute. The actual support depends on the PMD.
Same here
Quoted 12 lines
lib/librte_ethdev/rte_ethdev.h +10
-0+* +* - When set, to enable hairpin, the user should call the hairpin bind +* API after all the queues are set up properly and the ports are +* started. Also, the hairpin unbind API should be called accordingly +* before stopping a port that with hairpin configured. +* - When clear, the PMD will try to enable the hairpin with the queues +* configured automatically during port start. +*/ + uint32_t manual_bind:1; + uint32_t reserved:14; /**< Reserved bits. */struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; };
Re: [dpdk-dev] [PATCH v5 2/5] ethdev: add new attributes to hairpin config
Hi Thomas,
All comments are addressed and thanks a lot for the reviewing.
Quoted 106 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, October 15, 2020 6:46 PM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v5 2/5] ethdev: add new attributes to hairpin configExternal email: Use caution opening links or attachments
15/10/2020 07:35, Bing Zhao:
Quoted 1 line
To support two ports hairpin mode and keep the backward
compatibility
Quoted 1 line
for the application, two new attribute members of the hairpin
queue
Quoted 3 lines
configuration structure will be added.
tx_explicitmeans if the application itself will insert the TXpart
Quoted 2 lines
flow rules. If not set, PMD will insert the rules implicitly.
manual_bindmeans if the hairpin TX queue and peer RX queue willbe
Quoted 3 lines
bound automatically during the device start stage.
Different TX and RX queue pairs could have different values, but
it is
Quoted 1 line
highly recommended that all paired queues between one egress and
its
Quoted 2 lines
peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute
parameters
Quoted 3 lines
will be checked and decided by the PMD drivers.
In the single port hairpin, if both are zero without any setting,
the
Quoted 2 lines
behavior will remain the same as before. It means that no bind API needs to be called and no TX flow rules need to be inserted
manually
Quoted 6 lines
by the application.
Signed-off-by Bing Zhao <[email protected]>Acked-by Ori Kam <[email protected]>---
v4: squash document update and more info for the two newattributes
Quoted 2 lines
v2: optimize the structure and remove unused macros
---Acked-by Thomas Monjalon <[email protected]>Minor comments below.
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer {
Quoted 6 lines
struct
rte_eth_hairpin_conf{lib/librte_ethdev/rte_ethdev.h +4
-1-uint16_t peer_count;/**< The number of peers. */ + uint32_t peer_count:16; /**< The number of peers. */ + +/** +* Explicit TX flow rule mode. One hairpin pair of queues should have
Quoted 1 line
+ * the same attribute. The actual support depends on the PMD.
The second sentence should be on a separate line.
About the third sentence, implementation is always PMD-specific. PMD will reject the not supported conf, as usual.
I think this comment is not needed in the API description.Review
Quoted 2 lines
(quoted diff) +2
-0+ * + * - When set, the user should be responsible for insertingthe hairpin
Review
Quoted 2 lines
(quoted diff) +2
-0+ * TX part flows and removing them. + * - When clear, the PMD will try to handle the TX part ofthe flows,
lib/librte_ethdev/rte_ethdev.h struct rte_eth_hairpin_peer {
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +6
-0+* e.g., by splitting one flow into two parts. +*/ + uint32_t tx_explicit:1; + +/** +* Manually bind hairpin queues. One hairpin pair of queues should have
Quoted 1 line
+ * the same attribute. The actual support depends on the PMD.
Same here
Review
Quoted 2 lines
(quoted diff) +2
-0+ * + * - When set, to enable hairpin, the user should call thehairpin bind
Quoted 1 line
+ * API after all the queues are set up properly and the
ports are
Quoted 1 line
+ * started. Also, the hairpin unbind API should be called
accordingly
Review
Quoted 2 lines
(quoted diff) +2
-0+ * before stopping a port that with hairpin configured. + * - When clear, the PMD will try to enable the hairpin withthe queues
Quoted 6 lines
lib/librte_ethdev/rte_ethdev.h +4
-0+* configured automatically during port start. +*/ + uint32_t manual_bind:1; + uint32_t reserved:14; /**< Reserved bits. */struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ];};
PATCH v5 3/5 ethdev: add API to get hairpin peer ports list
In reply to Bing ZhaoAfter hairpin queues are configured, in general, the application will maintain the ports topology and even the queues configuration for the hairpin. But sometimes it will not.
If there is no hot-plug, it is easy to bind and unbind hairpin among all the ports. The application can just connect or disconnect the hairpin egress ports to/from all the probed ingress ports. Then all the connections could be handled properly.
But with hot-plug / hot-unplug, one port could be probed and removed dynamically. With two ports hairpin, all the connections from and to this port should be handled after start(bind) or before stop(unbind). It is necessary to know the hairpin topology with this port.
This function will return the ports list with the actual peer ports number after configuration. Either peer RX or TX ports will be gotten with this function call.
---
v5:
* change EINVAL to ENODEV
* add newline character
v4: add release notes update
v3:
* change the direction from bool to unsigned int type
* add length to protect the array from getting corrupted
--- doc/guides/rel_notes/release_20_11.rst | 1 + lib/librte_ethdev/rte_ethdev.c | 24 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 33 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 5 files changed, 89 insertions(+)
doc/guides/rel_notes/release_20_11.rst +1 -0
@@ -71,6 +71,7 @@ New Features New APIs are introduced to support binding / unbinding 2 ports hairpin. Hairpin TX part flow rules can be inserted explicitly. + New API is added to get the hairpin peer ports list. * **Updated Broadcom bnxt driver.**
lib/librte_ethdev/rte_ethdev.c +24 -0
@@ -2258,6 +2258,30 @@ struct rte_eth_dev *return ret; } +int +rte_eth_hairpin_get_peer_ports (uint16_t port_id,uint16_t *peer_ports, +size_t len,uint32_t direction) +{ +struct rte_eth_dev *dev; +int ret; + +if (!peer_ports || !len) +return -EINVAL ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_get_peer_ports, + -ENOTSUP ); + + ret = (*dev->dev_ops->hairpin_get_peer_ports)(dev, peer_ports, + len, direction); +if (ret <0 ) +RTE_ETHDEV_LOG (ERR ,"Failed to get %d hairpin peer %s ports\n" , + port_id, direction ?"RX" :"TX" ); + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)
lib/librte_ethdev/rte_ethdev.h +30 -0
@@ -2186,6 +2186,36 @@ int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,* @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice * +* Get all the hairpin peer RX / TX ports of the current port. +* The caller should ensure that the array is large enough to save the ports +* list. +* +* @param port_id +* The port identifier of the Ethernet device. +* @param peer_ports +* Pointer to the array to store the peer ports list. +* @param len +* Length of the array to store the port identifiers. +* @param direction +* Current port to peer port direction +* positive - current used as TX to get all peer RX ports. +* zero - current used as RX to get all peer TX ports. +* +* @return +* - (0 or positive) actual peer ports number. +* - (-EINVAL) if bad parameter. +* - (-ENODEV) if *port_id* invalid +* - (-ENOTSUP) if hardware doesn't support. +* - Others detailed errors from PMD drivers. +*/ +__rte_experimental +int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports, +size_t len,uint32_t direction); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* * Bind all hairpin TX queues of one port to the RX queues of the peer port. * It is only allowed to call this function after all hairpin queues are * configured properly and the devices are in started state.
lib/librte_ethdev/rte_ethdev_driver.h +33 -0
@@ -657,6 +657,37 @@ typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,/** * @internal +* Get all hairpin TX/RX peer ports of the current device, if any. +* +* @param dev +* ethdev handle of port. +* @param peer_ports +* array to save the ports list. +* @param len +* array length. +* @param direction +* value to decide the current to peer direction +* positive - used as TX to get all peer RX ports. +* zero - used as RX to get all peer TX ports. +* +* @return +* Negative errno value on error, 0 or positive on success. +* +* @retval 0 +* Success, no peer ports. +* @retval >0 +* Actual number of the peer ports. +* @retval -ENOTSUP +* Get peer ports API is not supported. +* @retval -EINVAL +* One of the parameters is invalid. +*/ +typedef int (*hairpin_get_peer_ports_t )(struct rte_eth_dev *dev, +uint16_t *peer_ports,size_t len, +uint32_t direction); + +/** +* @internal * Bind all hairpin TX queues of one port to the RX queues of the peer port. * * @param dev
@@ -849,6 +880,8 @@ struct eth_dev_ops {/**< Get Forward Error Correction(FEC) mode. */ eth_fec_set_t fec_set;/**< Set Forward Error Correction(FEC) mode. */ +hairpin_get_peer_ports_t hairpin_get_peer_ports; +/**< Get hairpin peer ports list. */ eth_hairpin_bind_t hairpin_bind;/**< Bind all hairpin TX queues of device to the peer port RX queues. */ eth_hairpin_unbind_t hairpin_unbind;
lib/librte_ethdev/rte_ethdev_version.map +1 -0
@@ -228,6 +228,7 @@ EXPERIMENTAL { # added in 20.11 rte_eth_hairpin_bind; + rte_eth_hairpin_get_peer_ports; rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str;
Signature · 1 line
1.8.3.1
PATCH v5 4/5 ethdev: add APIs for hairpin queue operation
In reply to Bing ZhaoEvery hairpin queue pair should be configured properly and the connection between TX and RX queues should be established, before hairpin function works. In single port hairpin mode, the queues of each pair belong to the same device. It is easy to get the hardware and software information of each queue and configure the hairpin connection with such information. In two ports hairpin mode, it is not easy or inappropriate to access one queue's information from another device.
Since hairpin is configured per queue pair, three new APIs are introduced and they are internal for the PMD using.
The peer update API helps to pass one queue's information to the peer queue and get the peer's information back for the next step. The peer bind API configures the current queue with the peer's information. For each hairpin queue pair, this API may need to be called twice to configure the TX, RX queues separately. The peer unbind API resets the current queue configuration and state to disconnect it from the peer queue. Also, it may need to be called twice to disconnect TX, RX queues from each other.
Some parameter of the above APIs might not be mandatory, and it depends on the PMD implementation.
The structure of rte_hairpin_peer_info is only a declaration and the actual members will be defined in each PMD when being used.
---
v5: commnets update
v3: change the direction from bool to unsigned int type
--- lib/librte_ethdev/rte_ethdev.c | 55 +++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 101 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 3 files changed, 159 insertions(+)
lib/librte_ethdev/rte_ethdev.c +55 -0
@@ -5624,6 +5624,61 @@ enum rte_eth_switch_domain_state {return 0 ; } +int +rte_eth_hairpin_queue_peer_update (uint16_t peer_port,uint16_t peer_queue, +struct rte_hairpin_peer_info *cur_info, +struct rte_hairpin_peer_info *peer_info, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +/* Current queue information is not mandatory. */ +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[peer_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_update, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_update)(dev, peer_queue, + cur_info, peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_bind (uint16_t cur_port,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_bind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_bind)(dev, cur_queue, + peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_unbind (uint16_t cur_port,uint16_t cur_queue, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_unbind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_unbind)(dev, cur_queue, + direction); +} +RTE_LOG_REGISTER (rte_eth_dev_logtype, lib.ethdev,INFO );RTE_INIT (ethdev_init_telemetry)
lib/librte_ethdev/rte_ethdev_driver.h +101 -0
125 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -254,6 +254,9 @@ INTERNAL { rte_eth_devargs_parse; rte_eth_dma_zone_free; rte_eth_dma_zone_reserve; + rte_eth_hairpin_queue_peer_bind; + rte_eth_hairpin_queue_peer_unbind; + rte_eth_hairpin_queue_peer_update; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; };
Signature · 1 line
1.8.3.1
PATCH v5 5/5 app/testpmd: change hairpin queues setup
In reply to Bing ZhaoA new parameter hairpin-mode is introduced to the testpmd command line. Bitmask value is used to provide a more flexible configuration. This parameter should be used when hairpinq is specified in the command line.
Bit 0 in the LSB indicates the hairpin will use the loop mode. The previous port RX queue will be connected to the current port TX queue.
Bit 1 in the LSB indicates the hairpin will use pair port mode. The even index port will be paired with the next odd index port. If the total number of the probed ports is odd, then the last one will be paired to itself.
If this byte is zero, then each port will be paired to itself. Bit 0 takes a higher priority in the checking.
Bit 4 in the second bytes indicate if the hairpin will use explicit TX flow mode.
e.g. in the command line, "--hairpinq=2 --hairpin-mode=0x11"
If not set, default value zero will be used and the behavior will try to get aligned with the previous single port mode. If the ports belong to different vendors' NICs, it is suggested to use the self hairpin mode only.
Since hairpin configures the hardware resources, the port mask of packets forwarding engine will not be used here.
---
v5: add newline character
v4: squash testpmd guide update
v2: move the hairpin bind/unbind into start/stop to support hot-plug
and hot-unplug
--- app/test-pmd/parameters.c | 15 ++++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++++++++++++++-- app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/run_app.rst | 8 +++ 4 files changed, 146 insertions(+), 4 deletions(-)
app/test-pmd/parameters.c +15 -0
@@ -222,6 +222,9 @@ "enabled\n");printf (" --record-core-cycles: enable measurement of CPU cycles.\n" );printf (" --record-burst-stats: enable display of RX and TX bursts.\n" ); +printf (" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n " +" 0x10 - explicit tx rule, 0x02 - hairpin ports paired\n" +" 0x01 - hairpin ports loop, 0x00 - hairpin port self\n" ); }#ifdef RTE_LIBRTE_CMDLINE
@@ -645,6 +648,7 @@ { "rxd", 1, 0, 0 }, { "txd", 1, 0, 0 }, { "hairpinq", 1, 0, 0 }, + { "hairpin-mode", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 },
@@ -1113,6 +1117,17 @@rte_exit (EXIT_FAILURE ,"Either rx or tx queues should " "be non-zero\n" ); } +if (!strcmp (lgopts[opt_idx].name,"hairpin-mode" )) { +char *end =NULL ; +unsigned int n; + + errno =0 ; + n =strtoul (optarg, &end,0 ); +if (errno !=0 || end == optarg) +rte_exit (EXIT_FAILURE ,"hairpin mode invalid\n" ); +else + hairpin_mode = (uint16_t )n; + }if (!strcmp (lgopts[opt_idx].name,"burst" )) { n =atoi (optarg);if (n ==0 ) {
app/test-pmd/testpmd.c +121 -4
195 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -398,6 +398,8 @@ struct queue_stats_mappings {extern uint16_t stats_period; +extern uint16_t hairpin_mode; +#ifdef RTE_LIBRTE_LATENCY_STATS extern uint8_t latencystats_enabled;extern lcoreid_t latencystats_lcore_id;
doc/guides/testpmd_app_ug/run_app.rst +8 -0
@@ -503,3 +503,11 @@ The command line options are: * ``--record-burst-stats`` Enable display of RX and TX burst stats. + +* ``--hairpin-mode=0xXX`` + + Set the hairpin port mode with bitmask, only valid when hairpin queues number is set. + bit 4 - explicit TX flow rule + bit 1 - two hairpin ports paired + bit 0 - two hairpin ports loop + The default value is 0. Hairpin will use single port mode and implicit TX flow mode.
Signature · 1 line
1.8.3.1
v6 cover introduce support for hairpin between two ports
In reply to Bing ZhaoThe patches contain the following changes:
1. new APIs to bind and unbind hairpin ports in manual binding mode.
2. new API to get the hairpin peer ports list.
3. new internal APIs for PMD to pass the queue information and configure the queue pair.
4. new attribute members in the hairpin queue configuraiton structure to specify the binding mode and enable explicit TX flow mode.
5. Testpmd support to configure the hairpin modes for two ports hairpin verification.
6. documents update.
---
v6:
1. Coding style updates
2. Using "Rx" & "Tx" instead of the capital formats
v5:
1. Change EINVAL to ENODEV if port id is invalid
2. Description fixes and other minor changes
v4:
1. squash documents update into patch
2. add more description of the hairpin conf attributes
v3:
1. add length to protect the pointer to the array from getting corrupted
2. change the direction from bool to unsigned int
v2:
1. add documents update
2. remove all peer ports logic from rte API
3. conf structure optimizing
4. new API to get the peer ports and testpmd change to support hot-plug / unplug case
---
Bing Zhao (5):
ethdev: add hairpin bind and unbind APIs
ethdev: add new attributes to hairpin config
ethdev: add API to get hairpin peer ports list
ethdev: add APIs for hairpin queue operation
app/testpmd: change hairpin queues setup
app/test-pmd/parameters.c | 15 +++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++- app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 3 + doc/guides/rel_notes/release_20_11.rst | 12 ++ doc/guides/testpmd_app_ug/run_app.rst | 8 ++ lib/librte_ethdev/rte_ethdev.c | 133 +++++++++++++++++++++- lib/librte_ethdev/rte_ethdev.h | 109 +++++++++++++++++- lib/librte_ethdev/rte_ethdev_driver.h | 186 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 6 + 10 files changed, 590 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v6 1/5 ethdev: add hairpin bind and unbind APIs
In single port hairpin mode, all the hairpin Tx and Rx queues belong to the same device. After the queues are set up properly, there is no other dependency between the Tx queue and its Rx peer queue. The binding process that connected the Tx and Rx queues together from hardware level will be done automatically during the device start procedure. Everything required is configured and initialized already for the binding process.
But in two ports hairpin mode, there will be some cross-dependences between two different ports. Usually, the ports will be initialized serially by the main thread but not in parallel. The earlier port will not be able to enable the bind if the following peer port is not yet configured with HW resources. What's more, if one port is detached / attached dynamically, it would introduce more trouble for the hairpin binding.
To overcome these, new APIs for binding and unbinding are added. During startup, only the hairpin Tx and Rx peer queues will be set up. Nothing will be done when starting the device if the queues are without auto-bind attribute. Only after the required ports pair started, the rte_eth_hairpin_bind() API can be called to bind the all Tx queues of the egress port to the Rx queues of the peer port. Then the connection between the egress and ingress ports pair will be established.
The rte_eth_hairpin_unbind() API could be used to disconnect the egress and the peer ingress ports. This should only be called before the device is closed if needed. When doing the clean up, all the egress and ingress pairs related to a single port should be taken into consideration, especially in the hot unplug case. mode is described.
---
v6:
* Coding style updates
* Using "Rx" & "Tx"
v5:
* Change EINVAL to ENODEV
* add newline character in the end of log line
* descriptions update
v4: squash release notes update
v2: remove the all peer ports logic from rte API
--- doc/guides/rel_notes/release_20_11.rst | 4 +++ lib/librte_ethdev/rte_ethdev.c | 46 ++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 52 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 52 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 2 ++ 5 files changed, 156 insertions(+)
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -89,6 +89,10 @@ New Features as flow action. * Added new flow APIs to create/update/destroy/query shared action. +* **Updated the ethdev library to support hairpin between two ports.** + + New APIs are introduced to support binding / unbinding 2 ports hairpin. + * **Updated Broadcom bnxt driver.** Updated the Broadcom bnxt driver with new features and improvements, including:
lib/librte_ethdev/rte_ethdev.c +46 -0
52 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev.h +52 -0
58 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_driver.h +52 -0
64 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +2 -0
@@ -227,6 +227,8 @@ EXPERIMENTAL { rte_tm_wred_profile_delete; # added in 20.11 + rte_eth_hairpin_bind; + rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str; rte_eth_fec_get_capability;
Signature · 1 line
1.8.3.1
PATCH v6 2/5 ethdev: add new attributes to hairpin config
In reply to Bing ZhaoTo support two ports hairpin mode and keep the backward compatibility for the application, two new attribute members of the hairpin queue configuration structure will be added.
tx_explicit means if the application itself will insert the Tx part flow rules. If not set, PMD will insert the rules implicitly. manual_bind means if the hairpin Tx queue and peer Rx queue will be bound automatically during the device start stage.
Different Tx and Rx queue pairs could have different values, but it is highly recommended that all paired queues between one egress and its peer ingress ports have the same values, in order not to bring any chaos to the system. The actual support of these attribute parameters will be checked and decided by the PMD drivers.
In the single port hairpin, if both are zero without any setting, the behavior will remain the same as before. It means that no bind API needs to be called and no Tx flow rules need to be inserted manually by the application.
---
v6: Using unnecessary comment and using "Rx" & "Tx"
v4: squash document update and more info for the two new attributes
v2: optimize the structure and remove unused macros
--- doc/guides/prog_guide/rte_flow.rst | 3 +++ doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_ethdev/rte_ethdev.c | 8 ++++---- lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++++++++++++++- 4 files changed, 40 insertions(+), 5 deletions(-)
doc/guides/prog_guide/rte_flow.rst +3 -0
@@ -2618,6 +2618,9 @@ set, unpredictable value will be seen depending on driver implementation. For loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to the other path depending on HW capability. +In hairpin case with Tx explicit flow mode, metadata could (not mandatory) be +used to connect the Rx and Tx flows if it can be propagated from Rx to Tx path. + .. _table_rte_flow_action_set_meta: .. table:: SET_META
doc/guides/rel_notes/release_20_11.rst +7 -0
@@ -92,6 +92,7 @@ New Features * **Updated the ethdev library to support hairpin between two ports.** New APIs are introduced to support binding / unbinding 2 ports hairpin. + Hairpin Tx part flow rules can be inserted explicitly. * **Updated Broadcom bnxt driver.**
@@ -396,6 +397,12 @@ ABI Changes Applications should use the new values for identification of existing extensions in the packet header. + * ``struct rte_eth_hairpin_conf`` has two new members: + + * ``uint32_t tx_explicit:1;`` + * ``uint32_t manual_bind:1;`` + + Known Issues ------------
lib/librte_ethdev/rte_ethdev.c +4 -4
@@ -2003,13 +2003,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_rx_2_tx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Rx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_rx_2_tx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Rx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Rx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
@@ -2174,13 +2174,13 @@ struct rte_eth_dev * }if (conf->peer_count > cap.max_tx_2_rx) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: <= %hu" , +"Invalid value for number of peers for Tx queue(=%u), should be: <= %hu" , conf->peer_count, cap.max_tx_2_rx);return -EINVAL ; }if (conf->peer_count ==0 ) {RTE_ETHDEV_LOG (ERR , -"Invalid value for number of peers for Tx queue(=%hu), should be: > 0" , +"Invalid value for number of peers for Tx queue(=%u), should be: > 0" , conf->peer_count);return -EINVAL ; }
lib/librte_ethdev/rte_ethdev.h +26 -1
@@ -1045,7 +1045,32 @@ struct rte_eth_hairpin_peer {* A structure used to configure hairpin binding. */ struct rte_eth_hairpin_conf { -uint16_t peer_count;/**< The number of peers. */ +uint32_t peer_count:16 ;/**< The number of peers. */ + +/** +* Explicit Tx flow rule mode. +* One hairpin pair of queues should have the same attribute. +* +* - When set, the user should be responsible for inserting the hairpin +* Tx part flows and removing them. +* - When clear, the PMD will try to handle the Tx part of the flows, +* e.g., by splitting one flow into two parts. +*/ +uint32_t tx_explicit:1 ; + +/** +* Manually bind hairpin queues. +* One hairpin pair of queues should have the same attribute. +* +* - When set, to enable hairpin, the user should call the hairpin bind +* function after all the queues are set up properly and the ports are +* started. Also, the hairpin unbind function should be called +* accordingly before stopping a port that with hairpin configured. +* - When clear, the PMD will try to enable the hairpin with the queues +* configured automatically during port start. +*/ +uint32_t manual_bind:1 ; +uint32_t reserved:14 ;/**< Reserved bits. */ struct rte_eth_hairpin_peer peers[RTE_ETH_MAX_HAIRPIN_PEERS ]; };
Signature · 1 line
1.8.3.1
PATCH v6 3/5 ethdev: add API to get hairpin peer ports list
In reply to Bing ZhaoAfter hairpin queues are configured, in general, the application will maintain the ports topology and even the queues configuration for the hairpin. But sometimes it will not.
If there is no hot-plug, it is easy to bind and unbind hairpin among all the ports. The application can just connect or disconnect the hairpin egress ports to/from all the probed ingress ports. Then all the connections could be handled properly.
But with hot-plug / hot-unplug, one port could be probed and removed dynamically. With two ports hairpin, all the connections from and to this port should be handled after start(bind) or before stop(unbind). It is necessary to know the hairpin topology with this port.
This function will return the ports list with the actual peer ports number after configuration. Either peer Rx or Tx ports will be gotten with this function call.
---
v6:
* Coding style updates
* Using "Rx" & "Tx"
v5:
* change EINVAL to ENODEV
* add newline character
v4: add release notes update
v3:
* change the direction from bool to unsigned int type
* add length to protect the array from getting corrupted
--- doc/guides/rel_notes/release_20_11.rst | 1 + lib/librte_ethdev/rte_ethdev.c | 24 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 30 +++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 33 ++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 1 + 5 files changed, 89 insertions(+)
doc/guides/rel_notes/release_20_11.rst +1 -0
@@ -93,6 +93,7 @@ New Features New APIs are introduced to support binding / unbinding 2 ports hairpin. Hairpin Tx part flow rules can be inserted explicitly. + New API is added to get the hairpin peer ports list. * **Updated Broadcom bnxt driver.**
lib/librte_ethdev/rte_ethdev.c +24 -0
@@ -2257,6 +2257,30 @@ struct rte_eth_dev *return ret; } +int +rte_eth_hairpin_get_peer_ports (uint16_t port_id,uint16_t *peer_ports, +size_t len,uint32_t direction) +{ +struct rte_eth_dev *dev; +int ret; + +if (peer_ports ==NULL || len ==0 ) +return -EINVAL ; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_get_peer_ports, + -ENOTSUP ); + + ret = (*dev->dev_ops->hairpin_get_peer_ports)(dev, peer_ports, + len, direction); +if (ret <0 ) +RTE_ETHDEV_LOG (ERR ,"Failed to get %d hairpin peer %s ports\n" , + port_id, direction ?"Rx" :"Tx" ); + +return ret; +} +void rte_eth_tx_buffer_drop_callback (struct rte_mbuf **pkts,uint16_t unsent, void *userdata __rte_unused)
lib/librte_ethdev/rte_ethdev.h +30 -0
@@ -2186,6 +2186,36 @@ int rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,* @warning * @b EXPERIMENTAL: this API may change, or be removed, without prior notice * +* Get all the hairpin peer Rx / Tx ports of the current port. +* The caller should ensure that the array is large enough to save the ports +* list. +* +* @param port_id +* The port identifier of the Ethernet device. +* @param peer_ports +* Pointer to the array to store the peer ports list. +* @param len +* Length of the array to store the port identifiers. +* @param direction +* Current port to peer port direction +* positive - current used as Tx to get all peer Rx ports. +* zero - current used as Rx to get all peer Tx ports. +* +* @return +* - (0 or positive) actual peer ports number. +* - (-EINVAL) if bad parameter. +* - (-ENODEV) if *port_id* invalid +* - (-ENOTSUP) if hardware doesn't support. +* - Others detailed errors from PMD drivers. +*/ +__rte_experimental +int rte_eth_hairpin_get_peer_ports(uint16_t port_id, uint16_t *peer_ports, +size_t len,uint32_t direction); + +/** +* @warning +* @b EXPERIMENTAL: this API may change, or be removed, without prior notice +* * Bind all hairpin Tx queues of one port to the Rx queues of the peer port. * It is only allowed to call this function after all hairpin queues are * configured properly and the devices are in started state.
lib/librte_ethdev/rte_ethdev_driver.h +33 -0
@@ -657,6 +657,37 @@ typedef int (*eth_fec_get_t)(struct rte_eth_dev *dev,/** * @internal +* Get all hairpin Tx/Rx peer ports of the current device, if any. +* +* @param dev +* ethdev handle of port. +* @param peer_ports +* array to save the ports list. +* @param len +* array length. +* @param direction +* value to decide the current to peer direction +* positive - used as Tx to get all peer Rx ports. +* zero - used as Rx to get all peer Tx ports. +* +* @return +* Negative errno value on error, 0 or positive on success. +* +* @retval 0 +* Success, no peer ports. +* @retval >0 +* Actual number of the peer ports. +* @retval -ENOTSUP +* Get peer ports API is not supported. +* @retval -EINVAL +* One of the parameters is invalid. +*/ +typedef int (*hairpin_get_peer_ports_t )(struct rte_eth_dev *dev, +uint16_t *peer_ports,size_t len, +uint32_t direction); + +/** +* @internal * Bind all hairpin Tx queues of one port to the Rx queues of the peer port. * * @param dev
@@ -849,6 +880,8 @@ struct eth_dev_ops {/**< Get Forward Error Correction(FEC) mode. */ eth_fec_set_t fec_set;/**< Set Forward Error Correction(FEC) mode. */ +hairpin_get_peer_ports_t hairpin_get_peer_ports; +/**< Get hairpin peer ports list. */ eth_hairpin_bind_t hairpin_bind;/**< Bind all hairpin Tx queues of device to the peer port Rx queues. */ eth_hairpin_unbind_t hairpin_unbind;
lib/librte_ethdev/rte_ethdev_version.map +1 -0
@@ -228,6 +228,7 @@ EXPERIMENTAL { # added in 20.11 rte_eth_hairpin_bind; + rte_eth_hairpin_get_peer_ports; rte_eth_hairpin_unbind; rte_eth_link_speed_to_str; rte_eth_link_to_str;
Signature · 1 line
1.8.3.1
PATCH v6 4/5 ethdev: add APIs for hairpin queue operation
In reply to Bing ZhaoEvery hairpin queue pair should be configured properly and the connection between Tx and Rx queues should be established, before hairpin function works. In single port hairpin mode, the queues of each pair belong to the same device. It is easy to get the hardware and software information of each queue and configure the hairpin connection with such information. In two ports hairpin mode, it is not easy or inappropriate to access one queue's information from another device.
Since hairpin is configured per queue pair, three new APIs are introduced and they are internal for the PMD using.
The peer update API helps to pass one queue's information to the peer queue and get the peer's information back for the next step. The peer bind API configures the current queue with the peer's information. For each hairpin queue pair, this API may need to be called twice to configure the Tx, Rx queues separately. The peer unbind API resets the current queue configuration and state to disconnect it from the peer queue. Also, it may need to be called twice to disconnect Tx, Rx queues from each other.
Some parameter of the above APIs might not be mandatory, and it depends on the PMD implementation.
The structure of rte_hairpin_peer_info is only a declaration and the actual members will be defined in each PMD when being used.
---
v6: Using "Rx" & "Tx"
v5: commnets update
v3: change the direction from bool to unsigned int type
--- lib/librte_ethdev/rte_ethdev.c | 55 +++++++++++++++++ lib/librte_ethdev/rte_ethdev_driver.h | 101 +++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_version.map | 3 + 3 files changed, 159 insertions(+)
lib/librte_ethdev/rte_ethdev.c +55 -0
@@ -5643,6 +5643,61 @@ enum rte_eth_switch_domain_state {return 0 ; } +int +rte_eth_hairpin_queue_peer_update (uint16_t peer_port,uint16_t peer_queue, +struct rte_hairpin_peer_info *cur_info, +struct rte_hairpin_peer_info *peer_info, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +/* Current queue information is not mandatory. */ +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[peer_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_update, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_update)(dev, peer_queue, + cur_info, peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_bind (uint16_t cur_port,uint16_t cur_queue, +struct rte_hairpin_peer_info *peer_info, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +if (peer_info ==NULL ) +return -EINVAL ; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_bind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_bind)(dev, cur_queue, + peer_info, direction); +} + +int +rte_eth_hairpin_queue_peer_unbind (uint16_t cur_port,uint16_t cur_queue, +uint32_t direction) +{ +struct rte_eth_dev *dev; + +/* No need to check the validity again. */ + dev = &rte_eth_devices[cur_port]; +RTE_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->hairpin_queue_peer_unbind, + -ENOTSUP ); + +return (*dev->dev_ops->hairpin_queue_peer_unbind)(dev, cur_queue, + direction); +} +RTE_LOG_REGISTER (rte_eth_dev_logtype, lib.ethdev,INFO );RTE_INIT (ethdev_init_telemetry)
lib/librte_ethdev/rte_ethdev_driver.h +101 -0
125 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_version.map +3 -0
@@ -258,6 +258,9 @@ INTERNAL { rte_eth_devargs_parse; rte_eth_dma_zone_free; rte_eth_dma_zone_reserve; + rte_eth_hairpin_queue_peer_bind; + rte_eth_hairpin_queue_peer_unbind; + rte_eth_hairpin_queue_peer_update; rte_eth_switch_domain_alloc; rte_eth_switch_domain_free; };
Signature · 1 line
1.8.3.1
PATCH v6 5/5 app/testpmd: change hairpin queues setup
In reply to Bing ZhaoA new parameter hairpin-mode is introduced to the testpmd command line. Bitmask value is used to provide a more flexible configuration. This parameter should be used when hairpinq is specified in the command line.
Bit 0 in the LSB indicates the hairpin will use the loop mode. The previous port Rx queue will be connected to the current port Tx queue.
Bit 1 in the LSB indicates the hairpin will use pair port mode. The even index port will be paired with the next odd index port. If the total number of the probed ports is odd, then the last one will be paired to itself.
If this byte is zero, then each port will be paired to itself. Bit 0 takes a higher priority in the checking.
Bit 4 in the second bytes indicate if the hairpin will use explicit Tx flow mode.
e.g. in the command line, "--hairpinq=2 --hairpin-mode=0x11"
If not set, default value zero will be used and the behavior will try to get aligned with the previous single port mode. If the ports belong to different vendors' NICs, it is suggested to use the self hairpin mode only.
Since hairpin configures the hardware resources, the port mask of packets forwarding engine will not be used here.
---
v6: using "Rx" & "Tx"
v5: add newline character
v4: squash testpmd guide update
v2: move the hairpin bind/unbind into start/stop to support hot-plug
and hot-unplug
--- app/test-pmd/parameters.c | 15 ++++ app/test-pmd/testpmd.c | 125 ++++++++++++++++++++++++++++++++-- app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/run_app.rst | 8 +++ 4 files changed, 146 insertions(+), 4 deletions(-)
app/test-pmd/parameters.c +15 -0
@@ -222,6 +222,9 @@ "enabled\n");printf (" --record-core-cycles: enable measurement of CPU cycles.\n" );printf (" --record-burst-stats: enable display of RX and TX bursts.\n" ); +printf (" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n " +" 0x10 - explicit Tx rule, 0x02 - hairpin ports paired\n" +" 0x01 - hairpin ports loop, 0x00 - hairpin port self\n" ); }#ifdef RTE_LIBRTE_CMDLINE
@@ -645,6 +648,7 @@ { "rxd", 1, 0, 0 }, { "txd", 1, 0, 0 }, { "hairpinq", 1, 0, 0 }, + { "hairpin-mode", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 },
@@ -1113,6 +1117,17 @@rte_exit (EXIT_FAILURE ,"Either rx or tx queues should " "be non-zero\n" ); } +if (!strcmp (lgopts[opt_idx].name,"hairpin-mode" )) { +char *end =NULL ; +unsigned int n; + + errno =0 ; + n =strtoul (optarg, &end,0 ); +if (errno !=0 || end == optarg) +rte_exit (EXIT_FAILURE ,"hairpin mode invalid\n" ); +else + hairpin_mode = (uint16_t )n; + }if (!strcmp (lgopts[opt_idx].name,"burst" )) { n =atoi (optarg);if (n ==0 ) {
app/test-pmd/testpmd.c +121 -4
195 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -408,6 +408,8 @@ struct queue_stats_mappings {extern uint16_t stats_period; +extern uint16_t hairpin_mode; +#ifdef RTE_LIBRTE_LATENCY_STATS extern uint8_t latencystats_enabled;extern lcoreid_t latencystats_lcore_id;
doc/guides/testpmd_app_ug/run_app.rst +8 -0
@@ -503,3 +503,11 @@ The command line options are: * ``--record-burst-stats`` Enable display of RX and TX burst stats. + +* ``--hairpin-mode=0xXX`` + + Set the hairpin port mode with bitmask, only valid when hairpin queues number is set. + bit 4 - explicit Tx flow rule + bit 1 - two hairpin ports paired + bit 0 - two hairpin ports loop + The default value is 0. Hairpin will use single port mode and implicit Tx flow mode.
Signature · 1 line
1.8.3.1
Quoted 32 lines · Bing Zhao
The patches contain the following changes:
1. new APIs to bind and unbind hairpin ports in manual binding mode.
2. new API to get the hairpin peer ports list.
3. new internal APIs for PMD to pass the queue information and configure the queue pair.
4. new attribute members in the hairpin queue configuraiton structure to specify the binding mode and enable explicit TX flow mode.
5. Testpmd support to configure the hairpin modes for two ports hairpin verification.
6. documents update.---
v6:
1. Coding style updates
2. Using "Rx" & "Tx" instead of the capital formats
v5:
1. Change EINVAL to ENODEV if port id is invalid
2. Description fixes and other minor changes
v4:
1. squash documents update into patch
2. add more description of the hairpin conf attributes
v3:
1. add length to protect the pointer to the array from getting corrupted
2. change the direction from bool to unsigned int
v2:
1. add documents update
2. remove all peer ports logic from rte API
3. conf structure optimizing
4. new API to get the peer ports and testpmd change to support hot-plug / unplug case
---
Quoted 7 lines
Bing Zhao (5):
ethdev: add hairpin bind and unbind APIs
ethdev: add new attributes to hairpin config
ethdev: add API to get hairpin peer ports list
ethdev: add APIs for hairpin queue operation
app/testpmd: change hairpin queues setup
Series applied to dpdk-next-net/main, thanks.
Hi Ferruh,
Quoted 59 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, October 16, 2020 7:03 AM
To: Bing Zhao <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]
Subject: Re: [PATCH v6 0/5] introduce support for hairpin between two portsExternal email: Use caution opening links or attachments
Quoted 2 lines · Bing Zhao
The patches contain the following changes:
1. new APIs to bind and unbind hairpin ports in manual bindingmode.
Quoted 4 lines
2. new API to get the hairpin peer ports list.
3. new internal APIs for PMD to pass the queue information and configure the queue pair.
4. new attribute members in the hairpin queue configuraitonstructure
Quoted 11 lines
to specify the binding mode and enable explicit TX flow mode.
5. Testpmd support to configure the hairpin modes for two ports hairpin verification.
6. documents update.---
v6:
1. Coding style updates
2. Using "Rx" & "Tx" instead of the capital formats v5:
1. Change EINVAL to ENODEV if port id is invalid 2. Descriptionfixes
Quoted 15 lines
and other minor changes
v4:
1. squash documents update into patch
2. add more description of the hairpin conf attributes v3:
1. add length to protect the pointer to the array from getting corrupted 2. change the direction from bool to unsigned int v2:
1. add documents update
2. remove all peer ports logic from rte API 3. conf structure optimizing 4. new API to get the peer ports and testpmd change to support
hot-plug / unplug case
---Quoted 7 lines
Bing Zhao (5):
ethdev: add hairpin bind and unbind APIs
ethdev: add new attributes to hairpin config
ethdev: add API to get hairpin peer ports list
ethdev: add APIs for hairpin queue operation
app/testpmd: change hairpin queues setup
Quoted 1 line
Series applied to dpdk-next-net/main, thanks.
Many thanks for your help.
BR. Bing