net/mlx5: introduce limit watermark and host shaper
PATCH v5 4/7 net/mlx5: add LWM event handling support
In reply to Spike DuWhen LWM meets RQ WQE, the kernel driver raises an event to SW. Use devx event_channel to catch this and to notify the user. Allocate this channel per shared device.
The channel has a cookie that informs the specific event port and queue.
--- drivers/net/mlx5/mlx5.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5.h | 7 +++++ drivers/net/mlx5/mlx5_devx.c | 47 +++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.c | 33 ++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 7 +++++ 5 files changed, 160 insertions(+)
drivers/net/mlx5/mlx5.c +66 -0
@@ -9,6 +9,7 @@#include <stdint.h> #include <stdlib.h> #include <errno.h> +#include <fcntl.h> #include <rte_malloc.h> #include <ethdev_driver.h>
@@ -22,6 +23,7 @@#include <rte_eal_paging.h> #include <rte_alarm.h> #include <rte_cycles.h> +#include <rte_interrupts.h> #include <mlx5_glue.h> #include <mlx5_devx_cmds.h>
@@ -1525,6 +1527,69 @@ struct mlx5_dev_ctx_shared * }/** +* Create LWM event_channel and interrupt handle for shared device +* context. All rxqs sharing the device context share the event_channel. +* A callback is registered in interrupt thread to receive the LWM event. +* +* @param[in] priv +* Pointer to mlx5_priv instance. +* +* @return +* 0 on success, negative with rte_errno set. +*/ +int +mlx5_lwm_setup (struct mlx5_priv *priv) +{ +int fd_lwm; + +pthread_mutex_init (&priv->sh->lwm_config_lock,NULL ); + priv->sh->devx_channel_lwm =mlx5_os_devx_create_event_channel + (priv->sh->cdev->ctx, +MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA ); +if (!priv->sh->devx_channel_lwm) + goto err; + fd_lwm =mlx5_os_get_devx_channel_fd (priv->sh->devx_channel_lwm); + priv->sh->intr_handle_lwm =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , true, + fd_lwm, mlx5_dev_interrupt_handler_lwm, priv); +if (!priv->sh->intr_handle_lwm) + goto err; +return 0 ; +err: +if (priv->sh->devx_channel_lwm) { +mlx5_os_devx_destroy_event_channel + (priv->sh->devx_channel_lwm); + priv->sh->devx_channel_lwm =NULL ; + } +pthread_mutex_destroy (&priv->sh->lwm_config_lock); +return -rte_errno; +} + +/** +* Destroy LWM event_channel and interrupt handle for shared device +* context before free this context. The interrupt handler is also +* unregistered. +* +* @param[in] sh +* Pointer to shared device context. +*/ +void +mlx5_lwm_unset (struct mlx5_dev_ctx_shared *sh) +{ +if (sh->intr_handle_lwm) { +mlx5_os_interrupt_handler_destroy (sh->intr_handle_lwm, + mlx5_dev_interrupt_handler_lwm, (void *)-1 ); + sh->intr_handle_lwm =NULL ; + } +if (sh->devx_channel_lwm) { +mlx5_os_devx_destroy_event_channel + (sh->devx_channel_lwm); + sh->devx_channel_lwm =NULL ; + } +pthread_mutex_destroy (&sh->lwm_config_lock); +} + +/** * Free shared IB device context. Decrement counter and if zero free * all allocated resources and close handles. *
@@ -1601,6 +1666,7 @@ struct mlx5_dev_ctx_shared *claim_zero (mlx5_devx_cmd_destroy (sh->td));MLX5_ASSERT (sh->geneve_tlv_option_resource ==NULL );pthread_mutex_destroy (&sh->txpp.mutex); +mlx5_lwm_unset (sh);mlx5_free (sh);return ; exit:
drivers/net/mlx5/mlx5.h +7 -0
@@ -1268,6 +1268,9 @@ struct mlx5_dev_ctx_shared {struct mlx5_lb_ctx self_lb;/* QP to enable self loopback for Devx. */ unsigned int flow_max_priority;enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM ]; +void *devx_channel_lwm; +struct rte_intr_handle *intr_handle_lwm; +pthread_mutex_t lwm_config_lock;/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1405,6 +1408,7 @@ enum mlx5_txq_modify_type { };struct mlx5_rxq_priv ; +struct mlx5_priv ;/* HW objects operations structure. */ struct mlx5_obj_ops {
@@ -1413,6 +1417,7 @@ struct mlx5_obj_ops {int (*rxq_event_get)(struct mlx5_rxq_obj *rxq_obj);int (*rxq_obj_modify)(struct mlx5_rxq_priv *rxq,uint8_t type);void (*rxq_obj_release)(struct mlx5_rxq_priv *rxq); +int (*rxq_event_get_lwm)(struct mlx5_priv *priv,int *rxq_idx,int *port_id);int (*ind_table_new)(struct rte_eth_dev *dev,const unsigned int log_n,struct mlx5_ind_table_obj *ind_tbl); int (*ind_table_modify)(struct rte_eth_dev *dev,
@@ -1603,6 +1608,8 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,bool mlx5_is_hpf (struct rte_eth_dev *dev);bool mlx5_is_sf_repr (struct rte_eth_dev *dev);void mlx5_age_event_prepare (struct mlx5_dev_ctx_shared *sh); +int mlx5_lwm_setup (struct mlx5_priv *priv); +void mlx5_lwm_unset (struct mlx5_dev_ctx_shared *sh);/* Macro to iterate over all valid ports for mlx5 driver. */ #define MLX5_ETH_FOREACH_DEV (port_id, dev) \
drivers/net/mlx5/mlx5_devx.c +47 -0
59 lines not on this page · raw message
drivers/net/mlx5/mlx5_rx.c +33 -0
@@ -1187,3 +1187,36 @@ int mlx5_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) {return -ENOTSUP ; } + +/** +* Rte interrupt handler for LWM event. +* It first checks if the event arrives, if so process the callback for +* RTE_ETH_EVENT_RX_LWM. +* +* @param args +* Generic pointer to mlx5_priv. +*/ +void +mlx5_dev_interrupt_handler_lwm (void *args) +{ +struct mlx5_priv *priv = args; +struct mlx5_rxq_priv *rxq; +struct rte_eth_dev *dev; +int ret, rxq_idx =0 , port_id =0 ; + + ret = priv->obj_ops.rxq_event_get_lwm (priv, &rxq_idx, &port_id); +if (unlikely (ret <0 )) { +DRV_LOG (WARNING ,"Cannot get LWM event context." ); +return ; + } +DRV_LOG (INFO ,"%s get LWM event, port_id:%d rxq_id:%d." , __func__, + port_id, rxq_idx); + dev = &rte_eth_devices[port_id]; + rxq =mlx5_rxq_get (dev, rxq_idx); +if (rxq) { +pthread_mutex_lock (&priv->sh->lwm_config_lock); + rxq->lwm_event_pending =1 ; +pthread_mutex_unlock (&priv->sh->lwm_config_lock); + } +rte_eth_dev_callback_process (dev,RTE_ETH_EVENT_RX_AVAIL_THRESH ,NULL ); +}
drivers/net/mlx5/mlx5_rx.h +7 -0
@@ -176,6 +176,7 @@ struct mlx5_rxq_priv {struct rte_eth_hairpin_conf hairpin_conf;/* Hairpin configuration. */ uint32_t hairpin_status;/* Hairpin binding status. */ uint32_t lwm:16; + uint32_t lwm_event_pending:1; };/* External RX queue descriptor. */
@@ -295,6 +296,7 @@ void mlx5_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,int mlx5_rx_burst_mode_get (struct rte_eth_dev *dev,uint16_t rx_queue_id,struct rte_eth_burst_mode *mode);int mlx5_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc); +void mlx5_dev_interrupt_handler_lwm (void *args);/* Vectorized version of mlx5_rx.c */ int mlx5_rxq_check_vec_support (struct mlx5_rxq_data *rxq_data);
@@ -675,4 +677,9 @@ uint16_t mlx5_rx_burst_mprq_vec(void *dpdk_rxq, struct rte_mbuf **pkts, return !!__atomic_load_n(&rxq->refcnt, __ATOMIC_RELAXED); } +#define LWM_COOKIE_RXQID_OFFSET 0 +#define LWM_COOKIE_RXQID_MASK 0xffff +#define LWM_COOKIE_PORTID_OFFSET 16 +#define LWM_COOKIE_PORTID_MASK 0xffff +#endif /* RTE_PMD_MLX5_RX_H_ */
Signature · 1 line
1.8.3.1
Re: [PATCH v5 0/7] introduce per-queue available descriptor threshold and host shaper
In reply to Spike Du@Matan, @Viacheslav, could you review mlx5 patches of the series, please.
Quoted 22 lines · Spike Du
available descriptor threshold(ADT for short) is per RX queue attribute, when RX queue available descriptors for HW is below ADT, HW sends an event to application. Host shaper can configure shaper rate and avail_thresh-triggered for a host port.
The shaper limits the rate of traffic from host port to embedded ARM rx port on Nvidia BlueField 2 NIC.
If avail_thresh-triggered is enabled, a 100Mbps shaper is enabled automatically when one of the host port's Rx queues receives available descriptor threshold event.These two features can combine to control traffic from host port to wire port for BlueField 2 NIC.
The traffic flows from host to embedded ARM, then to the physical port.
The work flow is on the ARM system, configure available descriptor threshold to RX queue and enable avail_thresh-triggered flag in host shaper, after receiving available descriptor threshold event, delay a while until RX queue is empty , then disable the shaper. We recycle this work flow to reduce RX queue drops on ARM system.Add new libethdev API to set available descriptor threshold, add rte event
RTE_ETH_EVENT_RX_AVAIL_THRESHto handle available descriptor threshold event. For host shaper, because it doesn't align to existing DPDK framework and is specific to Nvidia NIC, use PMD private API.For integration with testpmd, put the private cmdline function and available descriptor threshold event handler in mlx5 PMD directory by adding a new file
mlx5_testpmd.c. Follow David Marchand's driver specific commands framework to add mlx5 specific commands.Spike Du (7):
net/mlx5: add LWM support for Rxq
common/mlx5: share interrupt management
ethdev: introduce Rx queue based available descriptor threshold net/mlx5: add LWM event handling support
net/mlx5: support Rx queue based available descriptor threshold net/mlx5: add private API to config host port shaper app/testpmd: add Host Shaper command
PATCH v6 1/1 ethdev: introduce available Rx descriptors threshold
In reply to Spike DuFrom: Spike Du <[email protected]>
A new event RTE_ETH_EVENT_RX_AVAIL_THRESH should be generated by HW when number of available descriptors in Rx queue goes below the threshold.
The threshold is defined as a percentage of an Rx queue size with valid values from 0 to 99 (inclusive). Zero (default) value disables it.
There is no capability reporting for the feature. Application should simply try to set required threshold value and handle result.
Add testpmd commands to control the threshold:
set port <port_id> rxq <rxq_id> avail_thresh <avail_thresh_num>
---
v6:
- try to make descriptor shorter and more useful
- refine terminology to use "available descriptors threshold" everywhere (plural "descriptors")
- fix ethdev API documenation
- define negative return values
- define rules to convert percentage to descriptors number in drivers
- avoid extra checks in testpmd helper to allow ethdev API to do its job
- minor fixes in testpmd variables naming
- fix testpmd help to be human oriented
- update testpmd users guide
- add release notes
app/test-pmd/cmdline.c | 72 +++++++++++++++++++++ app/test-pmd/config.c | 9 +++ app/test-pmd/testpmd.c | 16 +++++ app/test-pmd/testpmd.h | 2 + doc/guides/rel_notes/release_22_07.rst | 6 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++ lib/ethdev/ethdev_driver.h | 25 +++++++ lib/ethdev/rte_ethdev.c | 44 +++++++++++++ lib/ethdev/rte_ethdev.h | 71 ++++++++++++++++++++ lib/ethdev/version.map | 2 + 10 files changed, 256 insertions(+)
app/test-pmd/cmdline.c +72 -0
@@ -750,6 +750,9 @@ static void cmd_help_long_parsed(void *parsed_result,"set port (port_id) fec_mode auto|off|rs|baser\n" " set fec mode for a specific port\n\n" +"set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n " +" set available descriptors threshold for Rx queue\n\n" + ,list_pkt_forwarding_modes () ); }
@@ -17331,6 +17334,74 @@ static cmdline_parse_inst_t cmd_set_fec_mode = { }, }; +/* *** set available descriptors threshold for an RxQ of a port *** */ +struct cmd_set_rxq_avail_thresh_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t port; +uint16_t port_num; +cmdline_fixed_string_t rxq; +uint16_t rxq_num; +cmdline_fixed_string_t avail_thresh; +uint8_t avail_thresh_num; +}; + +static void cmd_set_rxq_avail_thresh_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_rxq_avail_thresh_result *res = parsed_result; +int ret =0 ; + +if ((strcmp (res->set,"set" ) ==0 ) && (strcmp (res->port,"port" ) ==0 ) + && (strcmp (res->rxq,"rxq" ) ==0 ) + && (strcmp (res->avail_thresh,"avail_thresh" ) ==0 )) + ret =set_rxq_avail_thresh (res->port_num, res->rxq_num, + res->avail_thresh_num); +if (ret <0 ) +printf ("rxq_avail_thresh_cmd error: (%s)\n" ,strerror (-ret)); + +} + +static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, + set,"set" ); +static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, + port,"port" ); +static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, + port_num,RTE_UINT16 ); +static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, + rxq,"rxq" ); +static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum = + TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, + rxq_num,RTE_UINT16 ); +static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh = + TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, + avail_thresh,"avail_thresh" ); +static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum = + TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result, + avail_thresh_num,RTE_UINT8 ); + +static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = { + .f = cmd_set_rxq_avail_thresh_parsed, + .data = (void *)0 , + .help_str = +"set port <port_id> rxq <queue_id> avail_thresh <0..99>: " +"Set available descriptors threshold for Rx queue" , + .tokens = { + (void *)&cmd_set_rxq_avail_thresh_set, + (void *)&cmd_set_rxq_avail_thresh_port, + (void *)&cmd_set_rxq_avail_thresh_portnum, + (void *)&cmd_set_rxq_avail_thresh_rxq, + (void *)&cmd_set_rxq_avail_thresh_rxqnum, + (void *)&cmd_set_rxq_avail_thresh_avail_thresh, + (void *)&cmd_set_rxq_avail_thresh_avail_threshnum, +NULL , + }, +}; +/* show port supported ptypes */ /* Common result structure for show port ptypes */
@@ -18110,6 +18181,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific, (cmdline_parse_inst_t *)&cmd_show_fec_mode, (cmdline_parse_inst_t *)&cmd_set_fec_mode, + (cmdline_parse_inst_t *)&cmd_set_rxq_avail_thresh, (cmdline_parse_inst_t *)&cmd_show_capability, (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern, (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
app/test-pmd/config.c +9 -0
@@ -6392,3 +6392,12 @@ show_mcast_macs(portid_t port_id)printf (" %s\n" , buf); } } + +int +set_rxq_avail_thresh (portid_t port_id,uint16_t queue_id,uint8_t avail_thresh) +{ +if (port_id_is_invalid (port_id,ENABLED_WARN )) +return -EINVAL ; + +return rte_eth_rx_avail_thresh_set (port_id, queue_id, avail_thresh); +}
app/test-pmd/testpmd.c +16 -0
@@ -420,6 +420,7 @@ static const char * const eth_event_desc[] = { [RTE_ETH_EVENT_NEW] = "device probed", [RTE_ETH_EVENT_DESTROY] = "device released", [RTE_ETH_EVENT_FLOW_AGED] = "flow aged", + [RTE_ETH_EVENT_RX_AVAIL_THRESH] = "RxQ available descriptors threshold reached", [RTE_ETH_EVENT_MAX] = NULL, };
@@ -3672,6 +3673,21 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, ports[port_id].port_status =RTE_PORT_CLOSED ;printf ("Port %u is closed\n" , port_id);break ; +case RTE_ETH_EVENT_RX_AVAIL_THRESH : { +uint16_t rxq_id; +int ret; + +/* avail_thresh query API rewinds rxq_id, no need to check max RxQ num */ +for (rxq_id =0 ; ; rxq_id++) { + ret =rte_eth_rx_avail_thresh_query (port_id, &rxq_id, +NULL ); +if (ret <=0 ) +break ; +printf ("Received avail_thresh event, port:%u rxq_id:%u\n" , + port_id, rxq_id); + } +break ; + }default :break ; }
app/test-pmd/testpmd.h +2 -0
@@ -1190,6 +1190,8 @@ int update_jumbo_frame_offload(portid_t portid);void flex_item_create (portid_t port_id,uint16_t flex_id,const char *filename);void flex_item_destroy (portid_t port_id,uint16_t flex_id);void port_flex_item_flush (portid_t port_id); +int set_rxq_avail_thresh (portid_t port_id,uint16_t queue_id, +uint8_t avail_thresh); extern int flow_parse(const char *src, void *result, unsigned int size, struct rte_flow_attr **attr,
doc/guides/rel_notes/release_22_07.rst +6 -0
@@ -73,6 +73,12 @@ New Features * SFF-8472 revision 12.0 * SFF-8636 revision 2.7 +* **Added Rx queue available descriptors threshold and event.** + + Added ethdev API and corresponding driver operations to set Rx queue + available descriptors threshold and query for queues with reached + threshold when a new event RTE_ETH_EVENT_RX_AVAIL_THRESH is received. + * **Added vhost API to get the number of in-flight packets.** Added an API which can get the number of in-flight packets in
doc/guides/testpmd_app_ug/testpmd_funcs.rst +9 -0
@@ -2021,6 +2021,15 @@ Set fec mode for a specific port:: testpmd> set port (port_id) fec_mode auto|off|rs|baser +Set Rx queue available descriptors threshold +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Set available descriptors threshold for a specific Rx queue of port:: + + testpmd> set port (port_id) rxq (queue_id) avail_thresh (0..99) + +Use 0 value to disable the threshold and corresponding event. + Config Sample actions list ~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/ethdev/ethdev_driver.h +25 -0
@@ -1073,6 +1073,26 @@ typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev,*/ typedef int (*eth_dev_priv_dump_t )(struct rte_eth_dev *dev,FILE *file); +/** +* @internal Set Rx queue available descriptors threshold. +* @see rte_eth_rx_avail_thresh_set() +* +* Driver should round down number of descriptors on conversion from +* percentage. +*/ +typedef int (*eth_rx_queue_avail_thresh_set_t )(struct rte_eth_dev *dev, +uint16_t rx_queue_id, +uint8_t avail_thresh); + +/** +* @internal Query Rx queue available descriptors threshold event. +* @see rte_eth_rx_avail_thresh_query() +*/ + +typedef int (*eth_rx_queue_avail_thresh_query_t )(struct rte_eth_dev *dev, +uint16_t *rx_queue_id, +uint8_t *avail_thresh); +/** * @internal A structure containing the functions exported by an Ethernet driver. */
@@ -1283,6 +1303,11 @@ struct eth_dev_ops {/** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump; + +/** Set Rx queue available descriptors threshold */ +eth_rx_queue_avail_thresh_set_t rx_queue_avail_thresh_set; +/** Query Rx queue available descriptors threshold event */ +eth_rx_queue_avail_thresh_query_t rx_queue_avail_thresh_query; };/**
lib/ethdev/rte_ethdev.c +44 -0
50 lines not on this page · raw message
lib/ethdev/rte_ethdev.h +71 -0
89 lines not on this page · raw message
lib/ethdev/version.map +2 -0
@@ -279,6 +279,8 @@ EXPERIMENTAL { rte_flow_async_action_handle_update; # added in 22.07 + rte_eth_rx_avail_thresh_set; + rte_eth_rx_avail_thresh_query; rte_mtr_color_in_protocol_get; rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set;
Signature · 1 line
2.30.2
Re: [PATCH v6] ethdev: introduce available Rx descriptors threshold
08/06/2022 18:35, Andrew Rybchenko:
Quoted 17 lines
From: Spike Du <[email protected]>
A new event
RTE_ETH_EVENT_RX_AVAIL_THRESHshould be generated by HW when number of available descriptors in Rx queue goes below the threshold.The threshold is defined as a percentage of an Rx queue size with valid values from 0 to 99 (inclusive). Zero (default) value disables it.
There is no capability reporting for the feature. Application should simply try to set required threshold value and handle result.
Add testpmd commands to control the threshold:
set port <port_id> rxq <rxq_id>avail_thresh<avail_thresh_num>Signed-off-by Spike Du <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>
Quoted 15 lines
---
v6:
- try to make descriptor shorter and more useful
- refine terminology to use "available descriptors threshold" everywhere (plural "descriptors")
- fix ethdev API documenation
- define negative return values
- define rules to convert percentage to descriptors number in drivers
- avoid extra checks in testpmd helper to allow ethdev API to do its job
- minor fixes in testpmd variables naming
- fix testpmd help to be human oriented
- update testpmd users guide
- add release notes
What a (more than) review work, thanks a lot for this v6!
With a few minor arrangements,
applied, thanks.
Re: [PATCH v6] ethdev: introduce available Rx descriptors threshold
08/06/2022 19:22, Thomas Monjalon:
Quoted 34 lines
08/06/2022 18:35, Andrew Rybchenko:
Quoted 17 lines
From: Spike Du <[email protected]>
A new event
RTE_ETH_EVENT_RX_AVAIL_THRESHshould be generated by HW when number of available descriptors in Rx queue goes below the threshold.The threshold is defined as a percentage of an Rx queue size with valid values from 0 to 99 (inclusive). Zero (default) value disables it.
There is no capability reporting for the feature. Application should simply try to set required threshold value and handle result.
Add testpmd commands to control the threshold:
set port <port_id> rxq <rxq_id>avail_thresh<avail_thresh_num>Signed-off-by Spike Du <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>Quoted 15 lines
---
v6:
- try to make descriptor shorter and more useful
- refine terminology to use "available descriptors threshold" everywhere (plural "descriptors")
- fix ethdev API documenation
- define negative return values
- define rules to convert percentage to descriptors number in drivers
- avoid extra checks in testpmd helper to allow ethdev API to do its job
- minor fixes in testpmd variables naming
- fix testpmd help to be human oriented
- update testpmd users guide
- add release notes
Quoted 6 lines
What a (more than) review work, thanks a lot for this v6!
Acked-by Thomas Monjalon <[email protected]>With a few minor arrangements,
applied, thanks.
PS: some ABI exceptions have to be added as discussed in the thread:
+; Ignore ethdev event enum update
+; because new event cannot be received if not registered +[suppress_type]
+ type_kind = enum
+ changed_enumerators = RTE_ETH_EVENT_MAX
+
+; Ignore fields inserted in cacheline boundary of rte_eth_rxq_info +; because the struct size is unchanged
+[suppress_type]
+ name = rte_eth_rxq_info
+ has_data_member_inserted_between = {offset_of(rx_buf_size), end}
Re: [PATCH v5 1/7] net/mlx5: add LWM support for Rxq
In reply to Spike Duקבל Outlook עבור Android<https://aka.ms/AAb9ysg>
________________________________
From: Spike Du <[email protected]>
Sent: Tuesday, June 7, 2022 3:59:36 PM
To: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Raslan Darawsheh <[email protected]>
Subject: [PATCH v5 1/7] net/mlx5: add LWM support for Rxq
Add lwm(Limit WaterMark) field to Rxq object which indicates the percentage of RX queue size used by HW to raise LWM event to the user. Allow LWM setting in modify_rq command.
Allow the LWM configuration dynamically by adding RDY2RDY state change.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_devx.c | 13 ++++++++++++- drivers/net/mlx5/mlx5_devx.h | 1 + drivers/net/mlx5/mlx5_rx.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1395,6 +1395,7 @@ enum mlx5_rxq_modify_type {MLX5_RXQ_MOD_RST2RDY ,/* modify state from reset to ready. */ MLX5_RXQ_MOD_RDY2ERR ,/* modify state from ready to error. */ MLX5_RXQ_MOD_RDY2RST ,/* modify state from ready to reset. */ + MLX5_RXQ_MOD_RDY2RDY, /* modify state from ready to ready. */ }; enum mlx5_txq_modify_type {
drivers/net/mlx5/mlx5_devx.c +12 -1
@@ -62,7 +62,7 @@* @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ -static int +int mlx5_devx_modify_rq (struct mlx5_rxq_priv *rxq,uint8_t type) {struct mlx5_devx_modify_rq_attr rq_attr;
@@ -76,6 +76,11 @@case MLX5_RXQ_MOD_RST2RDY : rq_attr.rq_state =MLX5_RQC_STATE_RST ; rq_attr.state =MLX5_RQC_STATE_RDY ; +if (rxq->lwm) { + rq_attr.modify_bitmask |= +MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM ; + rq_attr.lwm = rxq->lwm; + }break ;case MLX5_RXQ_MOD_RDY2ERR : rq_attr.rq_state =MLX5_RQC_STATE_RDY ;
@@ -85,6 +90,12 @@ rq_attr.rq_state =MLX5_RQC_STATE_RDY ; rq_attr.state =MLX5_RQC_STATE_RST ;break ; +case MLX5_RXQ_MOD_RDY2RDY : + rq_attr.rq_state =MLX5_RQC_STATE_RDY ; + rq_attr.state =MLX5_RQC_STATE_RDY ; + rq_attr.modify_bitmask |=MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM ; + rq_attr.lwm = rxq->lwm; +break ;default :break ; }
drivers/net/mlx5/mlx5_devx.h +1 -0
@@ -11,6 +11,7 @@int mlx5_txq_devx_modify (struct mlx5_txq_obj *obj,enum mlx5_txq_modify_type type,uint8_t dev_port);void mlx5_txq_devx_obj_release (struct mlx5_txq_obj *txq_obj); +int mlx5_devx_modify_rq (struct mlx5_rxq_priv *rxq,uint8_t type);extern struct mlx5_obj_ops devx_obj_ops;
drivers/net/mlx5/mlx5_rx.h +1 -0
@@ -175,6 +175,7 @@ struct mlx5_rxq_priv {struct mlx5_devx_rq devx_rq;struct rte_eth_hairpin_conf hairpin_conf;/* Hairpin configuration. */ uint32_t hairpin_status;/* Hairpin binding status. */ + uint32_t lwm:16; };/* External RX queue descriptor. */
--
1.8.3.1
Re: [PATCH v6] ethdev: introduce available Rx descriptors threshold
In reply to Thomas MonjalonHi Thomas,
Could it possible accept the patch ' [dpdk-dev] [PATCH v7 1/4] ethdev: support device reset and recovery events'
which was delayed by ABI exceptions like this patch ?
PS: I noticed RC-1 was released just now and there may be no window left, but I think since this patch can be an
exception, why not that patch ?
Thanks.
Quoted 62 lines · Thomas Monjalon
08/06/2022 19:22, Thomas Monjalon:
Quoted 34 lines
08/06/2022 18:35, Andrew Rybchenko:
Quoted 17 lines
From: Spike Du <[email protected]>
A new event
RTE_ETH_EVENT_RX_AVAIL_THRESHshould be generated by HW when number of available descriptors in Rx queue goes below the threshold.The threshold is defined as a percentage of an Rx queue size with valid values from 0 to 99 (inclusive). Zero (default) value disables it.
There is no capability reporting for the feature. Application should simply try to set required threshold value and handle result.
Add testpmd commands to control the threshold:
set port <port_id> rxq <rxq_id>avail_thresh<avail_thresh_num>Signed-off-by Spike Du <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>Quoted 15 lines
---
v6:
- try to make descriptor shorter and more useful
- refine terminology to use "available descriptors threshold" everywhere (plural "descriptors")
- fix ethdev API documenation
- define negative return values
- define rules to convert percentage to descriptors number in drivers
- avoid extra checks in testpmd helper to allow ethdev API to do its job
- minor fixes in testpmd variables naming
- fix testpmd help to be human oriented
- update testpmd users guide
- add release notesQuoted 6 lines
What a (more than) review work, thanks a lot for this v6!
Acked-by Thomas Monjalon <[email protected]>With a few minor arrangements,
applied, thanks.PS: some ABI exceptions have to be added as discussed in the thread:
(quoted diff) +11
-0+; Ignore ethdev event enum update +; because new event cannot be received if not registered +[suppress_type] + type_kind = enum + changed_enumerators = RTE_ETH_EVENT_MAX + +; Ignore fields inserted in cacheline boundary of rte_eth_rxq_info +; because the struct size is unchanged +[suppress_type] + name = rte_eth_rxq_info + has_data_member_inserted_between = {offset_of(rx_buf_size), end}.
Re: [PATCH v6] ethdev: introduce available Rx descriptors threshold
09/06/2022 02:17, fengchengwen:
Quoted 4 lines
Hi Thomas,
Could it possible accept the patch ' [dpdk-dev] [PATCH v7 1/4] ethdev: support device reset and recovery events'
which was delayed by ABI exceptions like this patch ?
I suppose you refer to this explanation:
+; Ignore ethdev event enum update
+; because new event cannot be received if not registered
That's true we discussed in the past that it should have no effect on applications compiled with an old version of DPDK.
Quoted 2 lines
PS: I noticed RC-1 was released just now and there may be no window left, but I think since this patch can be an
exception, why not that patch ?
As far as I remember, the reset and recovery events patch have other comments to address before it can be accepted.
Re: [PATCH v5 7/7] app/testpmd: add Host Shaper command
In reply to Spike DuSince ethdev patch is factored out from the patch series the rest could go to mlx5 maintainers.
Quoted 23 lines · Spike Du
Add command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id>host_shaperavail_thresh_triggered<0|1> rate
<rate_num>- Example commands:
To enableavail_thresh_triggeredon port 1 and disable current host shaper:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered1 rate 0To disable
avail_thresh_triggeredand current host shaper on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 0The rate unit is 100Mbps.
To disableavail_thresh_triggeredand configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 50Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
Signed-off-by Spike Du <[email protected]>
[snip]
Quoted 28 lines
drivers/net/mlx5/mlx5_testpmd.c new file +28
-0+ +static uint8_t host_shaper_avail_thresh_triggered[RTE_MAX_ETHPORTS ]; +#define SHAPER_DISABLE_DELAY_US 100000/* 100ms */ + +/** +* Disable the host shaper and re-arm available descriptor threshold event. +* +* @param[in] args +* uint32_t integer combining port_id and rxq_id. +*/ +static void +mlx5_test_host_shaper_disable (void *args) +{ +uint32_t port_rxq_id = (uint32_t )(uintptr_t )args; +uint16_t port_id = port_rxq_id &0xffff ; +uint16_t qid = (port_rxq_id >>16 ) &0xffff ; +struct rte_eth_rxq_info qinfo; + +printf ("%s disable shaper\n" , __func__); +if (rte_eth_rx_queue_info_get (port_id, qid, &qinfo)) { +printf ("rx_queue_info_get returns error\n" ); +return ; + } +/* Rearm the available descriptor threshold event. */ +if (rte_eth_rx_avail_thresh_set (port_id, qid, qinfo.avail_thresh)) { +printf ("config avail_thresh returns error\n" ); +return ; + }
drivers/net/mlx5/mlx5_testpmd.c line 56
Quoted 10 lines
drivers/net/mlx5/mlx5_testpmd.c new file +10
-0+/* Only disable the shaper when avail_thresh_triggered is set. */ +if (host_shaper_avail_thresh_triggered[port_id] && +rte_pmd_mlx5_host_shaper_config (port_id,0 ,0 )) +printf ("%s disable shaper returns error\n" , __func__); +} + +void +mlx5_test_avail_thresh_event_handler (uint16_t port_id,uint16_t rxq_id) +{ +uint32_t port_rxq_id = port_id | (rxq_id <<16 );
Nobody guarantees here that port_id refers to an mlx5 port. It could be any port with avail_thres support.
Quoted 6 lines
drivers/net/mlx5/mlx5_testpmd.c new file +6
-0+ +rte_eal_alarm_set (SHAPER_DISABLE_DELAY_US , + mlx5_test_host_shaper_disable, + (void *)(uintptr_t )port_rxq_id); +printf ("%s port_id:%u rxq_id:%u\n" , __func__, port_id, rxq_id); +}
[snip]
drivers/net/mlx5/mlx5_testpmd.c line 143
Quoted 3 lines
drivers/net/mlx5/mlx5_testpmd.c new file +3
-0+cmdline_parse_token_string_t cmd_port_host_shaper_mlx5 = + TOKEN_STRING_INITIALIZER(struct cmd_port_host_shaper_result, + mlx5,"mlx5" );
I think it lucks 'static' keyword (many cases below).
[snip]
Re: [PATCH v6] ethdev: introduce available Rx descriptors threshold
In reply to Thomas MonjalonHi Thomas,
Quoted 7 lines · Thomas Monjalon
09/06/2022 02:17, fengchengwen:
Quoted 4 lines
Hi Thomas,
Could it possible accept the patch ' [dpdk-dev] [PATCH v7 1/4] ethdev: support device reset and recovery events'
which was delayed by ABI exceptions like this patch ?I suppose you refer to this explanation:
Yes
Quoted 4 lines
(quoted diff) +2
-0+; Ignore ethdev event enum update +; because new event cannot be received if not registered
Quoted 8 lines
That's true we discussed in the past that it should have no effect on applications compiled with an old version of DPDK.
Quoted 2 lines
PS: I noticed RC-1 was released just now and there may be no window left, but I think since this patch can be an
exception, why not that patch ?As far as I remember, the reset and recovery events patch have other comments to address before it can be accepted.
Yes, but the ABI exceptions is the primary cause of blockage.
There's two weeks left to fully discuss I think.
We have product requirements for this feature ("device reset and recovery events"), So:
Hi kalesh-anakkur,
Could you please send a new version about it ? If not, do you mind if I re-develop over it ?
Quoted 5 lines
.
RE: [PATCH v5 7/7] app/testpmd: add Host Shaper command
In reply to Andrew RybchenkoQuoted 78 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, June 9, 2022 3:55 PM
To: Spike Du <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Xiaoyun Li <[email protected]>; Aman Singh <[email protected]>; Yuying Zhang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v5 7/7] app/testpmd: add Host Shaper commandExternal email: Use caution opening links or attachments
Since ethdev patch is factored out from the patch series the rest could go to mlx5 maintainers.
Quoted 23 lines · Spike Du
Add command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id>host_shaperavail_thresh_triggered<0|1>
rate <rate_num>- Example commands:
To enableavail_thresh_triggeredon port 1 and disable current host shaper:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered1 rate 0To disable
avail_thresh_triggeredand current host shaper on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 0The rate unit is 100Mbps.
To disableavail_thresh_triggeredand configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 50Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
Signed-off-by Spike Du <[email protected]>[snip]
Quoted 31 lines
drivers/net/mlx5/mlx5_testpmd.c new file +31
-0+ +static uint8_t host_shaper_avail_thresh_triggered[RTE_MAX_ETHPORTS ]; +#define SHAPER_DISABLE_DELAY_US 100000/* 100ms */ + +/** +* Disable the host shaper and re-arm available descriptor threshold event. +* +* @param[in] args +* uint32_t integer combining port_id and rxq_id. +*/ +static void +mlx5_test_host_shaper_disable (void *args) { +uint32_t port_rxq_id = (uint32_t )(uintptr_t )args; +uint16_t port_id = port_rxq_id &0xffff ; +uint16_t qid = (port_rxq_id >>16 ) &0xffff ; +struct rte_eth_rxq_info qinfo; + +printf ("%s disable shaper\n" , __func__); +if (rte_eth_rx_queue_info_get (port_id, qid, &qinfo)) { +printf ("rx_queue_info_get returns error\n" ); +return ; + } +/* Rearm the available descriptor threshold event. */ +if (rte_eth_rx_avail_thresh_set (port_id, qid, qinfo.avail_thresh)) { +printf ("config avail_thresh returns error\n" ); +return ; + } +/* Only disable the shaper when avail_thresh_triggered is set. */ +if (host_shaper_avail_thresh_triggered[port_id] && +rte_pmd_mlx5_host_shaper_config (port_id,0 ,0 )) +printf ("%s disable shaper returns error\n" , __func__); }
Quoted 8 lines
drivers/net/mlx5/mlx5_testpmd.c line 56
Quoted 5 lines
drivers/net/mlx5/mlx5_testpmd.c new file +5
-0+ +void +mlx5_test_avail_thresh_event_handler (uint16_t port_id,uint16_t +rxq_id) { +uint32_t port_rxq_id = port_id | (rxq_id <<16 );Nobody guarantees here that
port_idrefers to an mlx5 port. It could be any port withavail_thressupport.
I think at the beginning of this function, we can add below check:
if (rte_eth_dev_info_get(port_id, &dev_info) != 0 ||
(strncmp(dev_info.driver_name, "mlx5", 4) != 0)) return;
is it ok?
Quoted 10 lines
Quoted 7 lines
drivers/net/mlx5/mlx5_testpmd.c new file +6
-0+ +rte_eal_alarm_set (SHAPER_DISABLE_DELAY_US , + mlx5_test_host_shaper_disable, + (void *)(uintptr_t )port_rxq_id); +printf ("%s port_id:%u rxq_id:%u\n" , __func__, port_id, rxq_id); +}[snip]
Quoted 5 lines
drivers/net/mlx5/mlx5_testpmd.c line 143
Quoted 3 lines
drivers/net/mlx5/mlx5_testpmd.c new file +3
-0+cmdline_parse_token_string_t cmd_port_host_shaper_mlx5 = + TOKEN_STRING_INITIALIZER(struct cmd_port_host_shaper_result, + mlx5,"mlx5" );I think it lucks 'static' keyword (many cases below).
Sure, will add 'static'.
Quoted 2 lines
[snip]
PATCH v6 1/1 app/testpmd: add Host Shaper command
In reply to Spike Duthis patch is taken out from series of "introduce per-queue available descriptor threshold and host shaper" to simplify the review, and it's the last one for non-PMD change.
However it depends on a PMD commit for host shaper config API, should be merged after PMD patches.
--
v6:
- add 'static' keyword for cmdline structs
- in AVAIL_THRESH event callback, add check to ensure it's mlx5 port
Spike Du (1):
app/testpmd: add Host Shaper command
app/test-pmd/testpmd.c | 11 +++ doc/guides/nics/mlx5.rst | 46 +++++++++ drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5_testpmd.c | 206 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++++ 5 files changed, 293 insertions(+) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
Signature · 1 line
1.8.3.1
PATCH v6 1/1 app/testpmd: add Host Shaper command
Add command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id> host_shaper avail_thresh_triggered <0|1> rate
<rate_num>
- Example commands:
To enable avail_thresh_triggered on port 1 and disable current host shaper:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0
To disable avail_thresh_triggered and current host shaper on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0
The rate unit is 100Mbps.
To disable avail_thresh_triggered and configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50
Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
--- app/test-pmd/testpmd.c | 11 +++ doc/guides/nics/mlx5.rst | 46 +++++++++ drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5_testpmd.c | 206 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++++ 5 files changed, 293 insertions(+) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
app/test-pmd/testpmd.c +11 -0
@@ -69,6 +69,9 @@#ifdef RTE_NET_BOND #include <rte_eth_bond.h> #endif +#ifdef RTE_NET_MLX5 +#include "mlx5_testpmd.h" +#endif #include "testpmd.h"
@@ -3659,6 +3662,14 @@ struct pmd_test_command {break ;printf ("Received avail_thresh event, port:%d rxq_id:%d\n" , port_id, rxq_id); + +struct rte_eth_dev_info dev_info; +if (rte_eth_dev_info_get (port_id, &dev_info) !=0 || + (strncmp (dev_info.driver_name,"mlx5" ,4 ) !=0 )) +printf ("%s\n" , dev_info.driver_name); +#ifdef RTE_NET_MLX5 +mlx5_test_avail_thresh_event_handler (port_id, rxq_id); +#endif }break ;default :
doc/guides/nics/mlx5.rst +46 -0
49 lines not on this page · raw message
drivers/net/mlx5/meson.build +4 -0
@@ -68,4 +68,8 @@ if get_option('buildtype').contains('debug') else cflags += [ '-UPEDANTIC' ] endif + +testpmd_sources += files('mlx5_testpmd.c') +testpmd_drivers_deps += 'net_mlx5' + subdir(exec_env)
drivers/net/mlx5/mlx5_testpmd.c new file +206 -0
206 lines not on this page · raw message
drivers/net/mlx5/mlx5_testpmd.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 6WIND S.A. +* Copyright 2021 Mellanox Technologies, Ltd +*/ + +#ifndef RTE_PMD_MLX5_TEST_H_ +#define RTE_PMD_MLX5_TEST_H_ + +#include <cmdline_parse.h> +#include <cmdline_parse_num.h> +#include <cmdline_parse_string.h> + +/** +* RTE_ETH_EVENT_RX_AVAIL_THRESH handler sample code. +* It's called in testpmd, the work flow here is delay a while until +* RX queueu is empty, then disable host shaper. +* +* @param[in] port_id +* Port identifier. +* @param[in] rxq_id +* Rx queue identifier. +*/ +void +mlx5_test_avail_thresh_event_handler (uint16_t port_id,uint16_t rxq_id); + +#endif
Signature · 1 line
1.8.3.1
Re: [PATCH v6] app/testpmd: add Host Shaper command
Hi Spike,
Quoted 50 lines · Spike Du
Add command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id>host_shaperavail_thresh_triggered<0|1> rate
<rate_num>- Example commands:
To enableavail_thresh_triggeredon port 1 and disable current host shaper:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered1 rate 0To disable
avail_thresh_triggeredand current host shaper on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 0The rate unit is 100Mbps.
To disableavail_thresh_triggeredand configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 50Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
Signed-off-by Spike Du <[email protected]>--- app/test-pmd/testpmd.c | 11 +++ doc/guides/nics/mlx5.rst | 46 +++++++++ drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5_testpmd.c | 206 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++++ 5 files changed, 293 insertions(+)create mode 100644
drivers/net/mlx5/mlx5_testpmd.ccreate mode 100644drivers/net/mlx5/mlx5_testpmd.happ/test-pmd/testpmd.c +3
-0@@ -69,6 +69,9 @@#ifdef RTE_NET_BOND #include <rte_eth_bond.h> #endif +#ifdef RTE_NET_MLX5 +#include "mlx5_testpmd.h" +#endif #include "testpmd.h" @@ -3659,6 +3662,14 @@ struct pmd_test_command {break ; printf("Received avail_thresh event, port:%d rxq_id:%d\n",
app/test-pmd/testpmd.c struct pmd_test_command { · line 3673
Quoted 10 lines
app/test-pmd/testpmd.c +8
-0port_id, rxq_id); + +struct rte_eth_dev_info dev_info; +if (rte_eth_dev_info_get (port_id, &dev_info) !=0 || + (strncmp (dev_info.driver_name,"mlx5" ,4 ) !=0 )) +printf ("%s\n" , dev_info.driver_name); +#ifdef RTE_NET_MLX5 +mlx5_test_avail_thresh_event_handler (port_id, rxq_id); +#endif }
Wanted to check the intend of above "if-statement". Currently i think only print() is dependent on it. Do we want to call mlx5 event_handler, only if driver_name is mlx5 ?
Quoted 3 lines
app/test-pmd/testpmd.c +0
-0break ;default :
<snip>
RE: [PATCH v6] app/testpmd: add Host Shaper command
Quoted 89 lines
-----Original Message-----
From: Singh, Aman Deep <[email protected]>
Sent: Tuesday, June 14, 2022 5:44 PM
To: Spike Du <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Wenzhuo Lu <[email protected]>; Beilei Xing <[email protected]>; Bernard Iremonger <[email protected]>; Shahaf Shuler <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Raslan Darawsheh <[email protected]>
Subject: Re: [PATCH v6] app/testpmd: add Host Shaper commandExternal email: Use caution opening links or attachments
Hi Spike,
Quoted 22 lines · Spike Du
Add command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id>host_shaperavail_thresh_triggered<0|1>
rate <rate_num>- Example commands:
To enableavail_thresh_triggeredon port 1 and disable current host shaper:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered1 rate 0To disable
avail_thresh_triggeredand current host shaper on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 0The rate unit is 100Mbps.
To disableavail_thresh_triggeredand configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 50Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
Quoted 6 lines
Signed-off-by Spike Du <[email protected]>--- app/test-pmd/testpmd.c | 11 +++ doc/guides/nics/mlx5.rst | 46 +++++++++ drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5_testpmd.c | 206++++++++++++++++++++++++++++++++++++++++
Quoted 22 lines
drivers/net/mlx5/mlx5_testpmd.h | 26 +++++ 5 files changed, 293 insertions(+)create mode 100644
drivers/net/mlx5/mlx5_testpmd.ccreate mode 100644drivers/net/mlx5/mlx5_testpmd.happ/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0
-033d9b85..e1ac75a 100644
app/test-pmd/testpmd.c +3
-0@@ -69,6 +69,9 @@#ifdef RTE_NET_BOND #include <rte_eth_bond.h> #endif +#ifdef RTE_NET_MLX5 +#include "mlx5_testpmd.h" +#endif #include "testpmd.h" @@ -3659,6 +3662,14 @@ struct pmd_test_command {break ; printf("Received avail_thresh event, port:%d rxq_id:%d\n",app/test-pmd/testpmd.c struct pmd_test_command { · line 3673
Quoted 10 lines
app/test-pmd/testpmd.c +8
-0port_id, rxq_id); + +struct rte_eth_dev_info dev_info; +if (rte_eth_dev_info_get (port_id, &dev_info) !=0 || + (strncmp (dev_info.driver_name,"mlx5" ,4 ) !=0 )) +printf ("%s\n" , dev_info.driver_name); +#ifdef RTE_NET_MLX5 +mlx5_test_avail_thresh_event_handler (port_id, +rxq_id);#endif }Wanted to check the intend of above "if-statement". Currently i think only
print()is dependent on it.
Do we want to call mlx5event_handler, only ifdriver_nameis mlx5 ?
Quoted 4 lines
Quoted 3 lines
app/test-pmd/testpmd.c +0
-0break ;default :<snip>
Sorry, it is test code that I should remove. The check of mlx5 driver_name Is done in mlx5_test_avail_thresh_event_handler(), if the port is not mlx5 port, We simply return there.
Will update the patch soon, thanks for the catch!
PATCH v7 1/1 app/testpmd: add Host Shaper command
In reply to Spike Duthis patch is taken out from series of "introduce per-queue available descriptor threshold and host shaper" to simplify the review, and it's the last one for non-PMD change.
However it depends on a PMD commit for host shaper config API, should be merged after PMD patches.
--
v7:
- remove some test code.
Spike Du (1):
app/testpmd: add Host Shaper command
app/test-pmd/testpmd.c | 7 ++ doc/guides/nics/mlx5.rst | 46 +++++++++ drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5_testpmd.c | 206 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++++ 5 files changed, 289 insertions(+) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
Signature · 1 line
1.8.3.1
PATCH v7 1/1 app/testpmd: add Host Shaper command
Add command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id> host_shaper avail_thresh_triggered <0|1> rate
<rate_num>
- Example commands:
To enable avail_thresh_triggered on port 1 and disable current host shaper:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0
To disable avail_thresh_triggered and current host shaper on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0
The rate unit is 100Mbps.
To disable avail_thresh_triggered and configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50
Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
--- app/test-pmd/testpmd.c | 7 ++ doc/guides/nics/mlx5.rst | 46 +++++++++ drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5_testpmd.c | 206 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++++ 5 files changed, 289 insertions(+) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
app/test-pmd/testpmd.c +7 -0
@@ -69,6 +69,9 @@#ifdef RTE_NET_BOND #include <rte_eth_bond.h> #endif +#ifdef RTE_NET_MLX5 +#include "mlx5_testpmd.h" +#endif #include "testpmd.h"
@@ -3659,6 +3662,10 @@ struct pmd_test_command {break ;printf ("Received avail_thresh event, port:%d rxq_id:%d\n" , port_id, rxq_id); + +#ifdef RTE_NET_MLX5 +mlx5_test_avail_thresh_event_handler (port_id, rxq_id); +#endif }break ;default :
doc/guides/nics/mlx5.rst +46 -0
49 lines not on this page · raw message
drivers/net/mlx5/meson.build +4 -0
@@ -68,4 +68,8 @@ if get_option('buildtype').contains('debug') else cflags += [ '-UPEDANTIC' ] endif + +testpmd_sources += files('mlx5_testpmd.c') +testpmd_drivers_deps += 'net_mlx5' + subdir(exec_env)
drivers/net/mlx5/mlx5_testpmd.c new file +206 -0
206 lines not on this page · raw message
drivers/net/mlx5/mlx5_testpmd.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 6WIND S.A. +* Copyright 2021 Mellanox Technologies, Ltd +*/ + +#ifndef RTE_PMD_MLX5_TEST_H_ +#define RTE_PMD_MLX5_TEST_H_ + +#include <cmdline_parse.h> +#include <cmdline_parse_num.h> +#include <cmdline_parse_string.h> + +/** +* RTE_ETH_EVENT_RX_AVAIL_THRESH handler sample code. +* It's called in testpmd, the work flow here is delay a while until +* RX queueu is empty, then disable host shaper. +* +* @param[in] port_id +* Port identifier. +* @param[in] rxq_id +* Rx queue identifier. +*/ +void +mlx5_test_avail_thresh_event_handler (uint16_t port_id,uint16_t rxq_id); + +#endif
Signature · 1 line
1.8.3.1
RE: [PATCH v7] app/testpmd: add Host Shaper command
From: Spike Du
Quoted 17 lines
Add command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id>host_shaperavail_thresh_triggered<0|1> rate
<rate_num>- Example commands:
To enableavail_thresh_triggeredon port 1 and disable current host shaper:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered1 rate 0To disable
avail_thresh_triggeredand current host shaper on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 0The rate unit is 100Mbps.
To disableavail_thresh_triggeredand configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 50
Quoted 5 lines
Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
Signed-off-by Spike Du <[email protected]>
Re: [PATCH v7] app/testpmd: add Host Shaper command
In reply to Spike DuFew comments below,
14/06/2022 14:01, Spike Du:
Quoted 23 lines
Add command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id>host_shaperavail_thresh_triggered<0|1> rate
<rate_num>- Example commands:
To enableavail_thresh_triggeredon port 1 and disable current host shaper:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered1 rate 0To disable
avail_thresh_triggeredand current host shaper on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 0The rate unit is 100Mbps.
To disableavail_thresh_triggeredand configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1host_shaperavail_thresh_triggered0 rate 50Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
Signed-off-by Spike Du <[email protected]>
[...]
app/test-pmd/testpmd.c struct pmd_test_command { · line 3668
Quoted 8 lines
app/test-pmd/testpmd.c +4
-0@@ -3659,6 +3662,10 @@ struct pmd_test_command {break ;printf ("Received avail_thresh event, port:%d rxq_id:%d\n" , port_id, rxq_id); + +#ifdef RTE_NET_MLX5 +mlx5_test_avail_thresh_event_handler (port_id, rxq_id); +#endif
This function includes a check of the driver in use for the port, so I assume it is OK to call it unconditionally here.
[...]
doc/guides/nics/mlx5.rst which can be installed from OFED mstflint package. · line 1732
Quoted 2 lines
doc/guides/nics/mlx5.rst +2
-0+How to use available descriptor threshold and Host Shaper +------------------------------
Underlining should be of same size as the title.
Review struct pmd_test_command {
Quoted 2 lines
(quoted diff) +2
-0+ +There are sample command lines to configure available descriptor threshold in testpmd.
Simpler:
There is a command to configure available descriptor threshold in testpmd.
You could add a link here to the doc of the command.
doc/guides/nics/mlx5.rst which can be installed from OFED mstflint package. · line 1743
Quoted 9 lines
doc/guides/nics/mlx5.rst +9
-0+Testpmd also contains sample logic to handle available descriptor threshold event. +The typical workflow is: testpmd configure available descriptor threshold for Rx queues, enable +avail_thresh_triggered in host shaper and register a callback, when traffic from host is +too high and Rx queue emptiness is below available descriptor threshold, PMD receives an event and +firmware configures a 100Mbps shaper on host port automatically, then PMD call +the callback registered previously, which will delay a while to let Rx queue +empty, then disable host shaper. + +Let's assume we have a simple Blue Field 2 setup: port 0 is uplink, port 1
There's no space in BlueField.
doc/guides/nics/mlx5.rst which can be installed from OFED mstflint package. · line 1754
Quoted 11 lines
doc/guides/nics/mlx5.rst +11
-0+is VF representor. Each port has 2 Rx queues. +In order to control traffic from host to ARM, we can enable available descriptor threshold in testpmd by: + +.. code-block:: console + + testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0 + testpmd> set port 1 rxq 0 avail_thresh 70 + testpmd> set port 1 rxq 1 avail_thresh 70 + +The first command disables current host shaper, and enables available descriptor threshold triggered mode. +The left commands configure available descriptor threshold to 70% of Rx queue size for both Rx queues,
left -> other
doc/guides/nics/mlx5.rst which can be installed from OFED mstflint package. · line 1759
Quoted 5 lines
doc/guides/nics/mlx5.rst +5
-0+When traffic from host is too high, you can see testpmd console prints log +about available descriptor threshold event receiving, then host shaper is disabled. +The traffic rate from host is controlled and less drop happens in Rx queues. + +When disable available descriptor threshold and avail_thresh_triggered, we can invoke below commands in testpmd:
Reword:
The threshold event and shaper can be disabled like this:
Quoted 16 lines
doc/guides/nics/mlx5.rst +16
-0+ +.. code-block:: console + + testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0 + testpmd> set port 1 rxq 0 avail_thresh 0 + testpmd> set port 1 rxq 1 avail_thresh 0 + +It's recommended an application disables available descriptor threshold and avail_thresh_triggered before exit, +if it enables them before. + +We can also configure the shaper with a value, the rate unit is 100Mbps, below +command sets current shaper to 5Gbps and disables avail_thresh_triggered. + +.. code-block:: console + + testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50
PATCH v8 2/6 common/mlx5: share interrupt management
In reply to Spike DuThere are many duplicate code of creating and initializing rte_intr_handle. Add a new mlx5_os API to do this, replace all PMD related code with this API.
--- drivers/common/mlx5/linux/mlx5_common_os.c | 131 ++++++++++++++++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 11 +++ drivers/common/mlx5/version.map | 2 + drivers/common/mlx5/windows/mlx5_common_os.h | 24 +++++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 71 -------------- drivers/net/mlx5/linux/mlx5_os.c | 132 ++++++--------------------- drivers/net/mlx5/linux/mlx5_socket.c | 53 ++--------- drivers/net/mlx5/mlx5.h | 2 - drivers/net/mlx5/mlx5_txpp.c | 28 ++---- drivers/net/mlx5/windows/mlx5_ethdev_os.c | 22 ----- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 48 ++-------- 11 files changed, 217 insertions(+), 307 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.c +131 -0
@@ -11,6 +11,7 @@#endif #include <dirent.h> #include <net/if.h> +#include <fcntl.h> #include <rte_errno.h> #include <rte_string_fns.h>
@@ -964,3 +965,133 @@claim_zero (mlx5_glue->dereg_mr (pmd_mr->obj));memset (pmd_mr,0 ,sizeof (*pmd_mr)); } + +/** +* Rte_intr_handle create and init helper. +* +* @param[in] mode +* interrupt instance can be shared between primary and secondary +* processes or not. +* @param[in] set_fd_nonblock +* Whether to set fd to O_NONBLOCK. +* @param[in] fd +* Fd to set in created intr_handle. +* @param[in] cb +* Callback to register for intr_handle. +* @param[in] cb_arg +* Callback argument for cb. +* +* @return +* - Interrupt handle on success. +* - NULL on failure, with rte_errno set. +*/ +struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg) +{ +struct rte_intr_handle *tmp_intr_handle; +int ret, flags; + + tmp_intr_handle =rte_intr_instance_alloc (mode); +if (!tmp_intr_handle) { + rte_errno =ENOMEM ; + goto err; + } +if (set_fd_nonblock) { + flags =fcntl (fd,F_GETFL ); + ret =fcntl (fd,F_SETFL , flags |O_NONBLOCK ); +if (ret) { + rte_errno = errno; + goto err; + } + } + ret =rte_intr_fd_set (tmp_intr_handle, fd); +if (ret) + goto err; + ret =rte_intr_type_set (tmp_intr_handle,RTE_INTR_HANDLE_EXT ); +if (ret) + goto err; + ret =rte_intr_callback_register (tmp_intr_handle, cb, cb_arg); +if (ret) { + rte_errno = -ret; + goto err; + } +return tmp_intr_handle; +err: +if (tmp_intr_handle) +rte_intr_instance_free (tmp_intr_handle); +return NULL ; +} + +/* Safe unregistration for interrupt callback. */ +static void +mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, +rte_intr_callback_fn cb_fn,void *cb_arg) +{ +uint64_t twait =0 ; +uint64_t start =0 ; + +do { +int ret; + + ret =rte_intr_callback_unregister (handle, cb_fn, cb_arg); +if (ret >=0 ) +return ; +if (ret != -EAGAIN ) { +DRV_LOG (INFO ,"failed to unregister interrupt" +" handler (error: %d)" , ret); +MLX5_ASSERT (false); +return ; + } +if (twait) { +struct timespec onems; + +/* Wait one millisecond and try again. */ + onems.tv_sec =0 ; + onems.tv_nsec =NS_PER_S /MS_PER_S ; +nanosleep (&onems,0 ); +/* Check whether one second elapsed. */ +if ((rte_get_timer_cycles () - start) <= twait) +continue ; + }else { +/* +* We get the amount of timer ticks for one second. +* If this amount elapsed it means we spent one +* second in waiting. This branch is executed once +* on first iteration. +*/ + twait =rte_get_timer_hz (); +MLX5_ASSERT (twait); + } +/* +* Timeout elapsed, show message (once a second) and retry. +* We have no other acceptable option here, if we ignore +* the unregistering return code the handler will not +* be unregistered, fd will be closed and we may get the +* crush. Hanging and messaging in the loop seems not to be +* the worst choice. +*/ +DRV_LOG (INFO ,"Retrying to unregister interrupt handler" ); + start =rte_get_timer_cycles (); + }while (true); +} + +/** +* Rte_intr_handle destroy helper. +* +* @param[in] intr_handle +* Rte_intr_handle to destroy. +* @param[in] cb +* Callback which is registered to intr_handle. +* @param[in] cb_arg +* Callback argument for cb. +* +*/ +void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg) +{ +if (rte_intr_fd_get (intr_handle) >=0 ) +mlx5_intr_callback_unregister (intr_handle, cb, cb_arg); +rte_intr_instance_free (intr_handle); +}
drivers/common/mlx5/linux/mlx5_common_os.h +11 -0
@@ -15,6 +15,7 @@#include <rte_log.h> #include <rte_kvargs.h> #include <rte_devargs.h> +#include <rte_interrupts.h> #include "mlx5_autoconf.h" #include "mlx5_glue.h"
@@ -299,4 +300,14 @@int mlx5_get_device_guid (const struct rte_pci_addr *dev,uint8_t *guid,size_t len); +__rte_internal +struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg); + +__rte_internal +void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg); +#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/version.map +2 -0
@@ -153,5 +153,7 @@ INTERNAL { mlx5_mr_mempool2mr_bh; mlx5_mr_mempool_populate_cache; + mlx5_os_interrupt_handler_create; # WINDOWS_NO_EXPORT + mlx5_os_interrupt_handler_destroy; # WINDOWS_NO_EXPORT local: *; };
drivers/common/mlx5/windows/mlx5_common_os.h +24 -0
@@ -9,6 +9,7 @@#include <sys/types.h> #include <rte_errno.h> +#include <rte_interrupts.h> #include "mlx5_autoconf.h" #include "mlx5_glue.h"
@@ -253,4 +254,27 @@__rte_internal int mlx5_os_umem_dereg(void *pumem); +static inline struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg) +{ + (void )mode; + (void )set_fd_nonblock; + (void )fd; + (void )cb; + (void )cb_arg; + rte_errno =ENOTSUP ; +return NULL ; +} + +static inline void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg) +{ + (void )intr_handle; + (void )cb; + (void )cb_arg; +} + +#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/net/mlx5/linux/mlx5_ethdev_os.c +0 -71
77 lines not on this page · raw message
drivers/net/mlx5/linux/mlx5_os.c +29 -103
169 lines not on this page · raw message
drivers/net/mlx5/linux/mlx5_socket.c +6 -47
71 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +0 -2
@@ -1682,8 +1682,6 @@ int mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info);void mlx5_translate_port_name (const char *port_name_in,struct mlx5_switch_info *port_info_out); -void mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, -rte_intr_callback_fn cb_fn,void *cb_arg);int mlx5_sysfs_bond_info (unsigned int pf_ifindex,unsigned int *ifindex,char *ifname); int mlx5_get_module_info(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_txpp.c +7 -21
@@ -741,11 +741,8 @@static void mlx5_txpp_stop_service (struct mlx5_dev_ctx_shared *sh) { -if (!rte_intr_fd_get (sh->txpp.intr_handle)) -return ; -mlx5_intr_callback_unregister (sh->txpp.intr_handle, - mlx5_txpp_interrupt_handler, sh); -rte_intr_instance_free (sh->txpp.intr_handle); +mlx5_os_interrupt_handler_destroy (sh->txpp.intr_handle, + mlx5_txpp_interrupt_handler, sh); }/* Attach interrupt handler and fires first request to Rearm Queue. */
@@ -769,23 +766,12 @@ rte_errno = errno;return -rte_errno; } - sh->txpp.intr_handle = -rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_SHARED ); -if (sh->txpp.intr_handle ==NULL ) { -DRV_LOG (ERR ,"Fail to allocate intr_handle" ); -return -ENOMEM ; - } fd =mlx5_os_get_devx_channel_fd (sh->txpp.echan); -if (rte_intr_fd_set (sh->txpp.intr_handle, fd)) -return -rte_errno; - -if (rte_intr_type_set (sh->txpp.intr_handle,RTE_INTR_HANDLE_EXT )) -return -rte_errno; - -if (rte_intr_callback_register (sh->txpp.intr_handle, - mlx5_txpp_interrupt_handler, sh)) { -rte_intr_fd_set (sh->txpp.intr_handle,0 ); -DRV_LOG (ERR ,"Failed to register CQE interrupt %d." , rte_errno); + sh->txpp.intr_handle =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , false, + fd, mlx5_txpp_interrupt_handler, sh); +if (!sh->txpp.intr_handle) { +DRV_LOG (ERR ,"Fail to allocate intr_handle" );return -rte_errno; }/* Subscribe CQ event to the event channel controlled by the driver. */
drivers/net/mlx5/windows/mlx5_ethdev_os.c +0 -22
@@ -140,28 +140,6 @@return 0 ; } -/* -* Unregister callback handler safely. The handler may be active -* while we are trying to unregister it, in this case code -EAGAIN -* is returned by rte_intr_callback_unregister(). This routine checks -* the return code and tries to unregister handler again. -* -* @param handle -* interrupt handle -* @param cb_fn -* pointer to callback routine -* @cb_arg -* opaque callback parameter -*/ -void -mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, -rte_intr_callback_fn cb_fn,void *cb_arg) -{ -RTE_SET_USED (handle); -RTE_SET_USED (cb_fn); -RTE_SET_USED (cb_arg); -} -/** * DPDK callback to get flow control status. *
drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +7 -41
64 lines not on this page · raw message
Signature · 1 line
1.8.3.1
v8 cover introduce per-queue available descriptor threshold and host shaper
In reply to Spike Duavailable descriptor threshold(ADT for short) is per RX queue attribute, when RX queue available descriptors for HW is below ADT, HW sends an event to application. Host shaper can configure shaper rate and avail_thresh-triggered for a host port.
The shaper limits the rate of traffic from host port to embedded ARM rx port on Nvidia BlueField 2 NIC.
If avail_thresh-triggered is enabled, a 100Mbps shaper is enabled automatically when one of the host port's Rx queues receives available descriptor threshold event.
These two features can combine to control traffic from host port to wire port for BlueField 2 NIC.
The traffic flows from host to embedded ARM, then to the physical port.
The work flow is on the ARM system, configure available descriptor threshold to RX queue and enable avail_thresh-triggered flag in host shaper, after receiving available descriptor threshold event, delay a while until RX queue is empty , then disable the shaper. We recycle this work flow to reduce RX queue drops on ARM system.
Add new libethdev API to set available descriptor threshold, add rte event RTE_ETH_EVENT_RX_AVAIL_THRESH to handle available descriptor threshold event. For host shaper, because it doesn't align to existing DPDK framework and is specific to Nvidia NIC, use PMD private API.
For integration with testpmd, put the private cmdline function and available descriptor threshold event handler in mlx5 PMD directory by adding a new file mlx5_testpmd.c. Follow David Marchand's driver specific commands framework to add mlx5 specific commands.
Spike Du (6):
net/mlx5: add LWM support for Rxq
common/mlx5: share interrupt management
net/mlx5: add LWM event handling support
net/mlx5: support Rx queue based available descriptor threshold net/mlx5: add private API to config host port shaper app/testpmd: add Host Shaper command
app/test-pmd/testpmd.c | 7 + doc/guides/nics/mlx5.rst | 93 +++++++++ doc/guides/rel_notes/release_22_07.rst | 2 + drivers/common/mlx5/linux/meson.build | 13 ++ drivers/common/mlx5/linux/mlx5_common_os.c | 131 ++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 11 + drivers/common/mlx5/mlx5_prm.h | 26 +++ drivers/common/mlx5/version.map | 2 + drivers/common/mlx5/windows/mlx5_common_os.h | 24 +++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 71 ------- drivers/net/mlx5/linux/mlx5_os.c | 132 +++--------- drivers/net/mlx5/linux/mlx5_socket.c | 53 +---- drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5.c | 68 +++++++ drivers/net/mlx5/mlx5.h | 12 +- drivers/net/mlx5/mlx5_devx.c | 60 +++++- drivers/net/mlx5/mlx5_devx.h | 1 + drivers/net/mlx5/mlx5_rx.c | 288 +++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 13 ++ drivers/net/mlx5/mlx5_testpmd.c | 205 +++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++ drivers/net/mlx5/mlx5_txpp.c | 28 +-- drivers/net/mlx5/rte_pmd_mlx5.h | 30 +++ drivers/net/mlx5/version.map | 2 + drivers/net/mlx5/windows/mlx5_ethdev_os.c | 22 -- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 48 +---- 26 files changed, 1064 insertions(+), 308 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
Signature · 1 line
1.8.3.1
PATCH v8 5/6 net/mlx5: add private API to config host port shaper
Host port shaper can be configured with QSHR(QoS Shaper Host Register). Add check in build files to enable this function or not.
The host shaper configuration affects all the ethdev ports belonging to the same host port.
Host shaper can configure shaper rate and lwm-triggered for a host port. The shaper limits the rate of traffic from host port to wire port. If lwm-triggered is enabled, a 100Mbps shaper is enabled automatically when one of the host port's Rx queues receives available descriptor threshold event.
--- doc/guides/nics/mlx5.rst | 35 +++++++++++ doc/guides/rel_notes/release_22_07.rst | 1 + drivers/common/mlx5/linux/meson.build | 13 +++++ drivers/common/mlx5/mlx5_prm.h | 25 ++++++++ drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_rx.c | 104 +++++++++++++++++++++++++++++++++ drivers/net/mlx5/rte_pmd_mlx5.h | 30 ++++++++++ drivers/net/mlx5/version.map | 2 + 8 files changed, 212 insertions(+)
doc/guides/nics/mlx5.rst +35 -0
@@ -94,6 +94,7 @@ Features - Sub-Function representors. - Sub-Function. - Rx queue available descriptor threshold configuration. +- Host shaper support. Limitations
@@ -525,6 +526,12 @@ Limitations - Doesn't support shared Rx queue and Hairpin Rx queue. +- Host shaper: + + - Support BlueField series NIC from BlueField 2. + - When configure host shaper with MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED flag set, + only rate 0 and 100Mbps are supported. + Statistics ----------
@@ -1692,3 +1699,31 @@ Available descriptor threshold is a per Rx queue attribute, it should be configu a percentage of the Rx queue size. When Rx queue available descriptors for hardware are below the threshold, an event is sent to PMD. +Host shaper introduction +------------------------ + +Host shaper register is per host port register which sets a shaper +on the host port. +All VF/hostPF representors belonging to one host port share one host shaper. +For example, if representor 0 and representor 1 belong to same host port, +and a host shaper rate of 1Gbps is configured, the shaper throttles both +representors' traffic from host. +Host shaper has two modes for setting the shaper, immediate and deferred to +available descriptor threshold event trigger. In immediate mode, the rate limit is configured +immediately to host shaper. When deferring to available descriptor threshold trigger, the shaper +is not set until an available descriptor threshold event is received by any Rx queue in a VF +representor belonging to the host port. The only rate supported for deferred +mode is 100Mbps (there is no limit on the supported rates for immediate mode). +In deferred mode, the shaper is set on the host port by the firmware upon +receiving the available descriptor threshold event, which allows throttling host traffic on +available descriptor threshold events at minimum latency, preventing excess drops in the +Rx queue. + +Host shaper dependency for mstflint package +------------------------------------------- + +In order to configure host shaper register, ``librte_net_mlx5`` depends on ``libmtcr_ul`` +which can be installed from OFED mstflint package. +Meson detects ``libmtcr_ul`` existence at configure stage. +If the library is detected, the application must link with ``-lmtcr_ul``, +as done by the pkg-config file libdpdk.pc.
doc/guides/rel_notes/release_22_07.rst +1 -0
@@ -90,6 +90,7 @@ New Features * Added support for MTU on Windows. * Added matching and RSS on IPsec ESP. * Added Rx queue available descriptor threshold support. + * Added host shaper support. * **Updated Marvell cnxk crypto driver.**
drivers/common/mlx5/linux/meson.build +13 -0
@@ -45,6 +45,13 @@ if static_ibverbs ext_deps += declare_dependency(link_args:ibv_ldflags.split()) endif +libmtcr_ul_found = false +lib = cc.find_library('mtcr_ul', required:false) +if lib.found() and run_command('meson', '--version').stdout().version_compare('>= 0.49.2') + libmtcr_ul_found = true + ext_deps += lib +endif + sources += files('mlx5_nl.c') sources += files('mlx5_common_auxiliary.c') sources += files('mlx5_common_os.c')
@@ -207,6 +214,12 @@ has_sym_args = [ [ 'HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR', 'infiniband/verbs.h', 'ibv_import_device' ], ] +if libmtcr_ul_found + has_sym_args += [ + [ 'HAVE_MLX5_MSTFLINT', 'mstflint/mtcr.h', + 'mopen'], + ] +endif config = configuration_data() foreach arg:has_sym_args config.set(arg[0], cc.has_header_symbol(arg[1], arg[2], dependencies: libs))
drivers/common/mlx5/mlx5_prm.h +25 -0
@@ -3771,6 +3771,7 @@ enum {MLX5_CRYPTO_COMMISSIONING_REGISTER_ID =0xC003 ,MLX5_IMPORT_KEK_HANDLE_REGISTER_ID =0xC004 ,MLX5_CREDENTIAL_HANDLE_REGISTER_ID =0xC005 , + MLX5_QSHR_REGISTER_ID = 0x4030, }; struct mlx5_ifc_register_mtutc_bits {
@@ -3785,6 +3786,30 @@ struct mlx5_ifc_register_mtutc_bits {u8 time_adjustment[0x20 ]; }; +struct mlx5_ifc_ets_global_config_register_bits { +u8 reserved_at_0[0x2 ]; +u8 rate_limit_update[0x1 ]; +u8 reserved_at_3[0x29 ]; +u8 max_bw_units[0x4 ]; +u8 reserved_at_48[0x8 ]; +u8 max_bw_value[0x8 ]; +}; + +#define ETS_GLOBAL_CONFIG_BW_UNIT_DISABLED 0x0 +#define ETS_GLOBAL_CONFIG_BW_UNIT_HUNDREDS_MBPS 0x3 +#define ETS_GLOBAL_CONFIG_BW_UNIT_GBPS 0x4 + +struct mlx5_ifc_register_qshr_bits { +u8 reserved_at_0[0x4 ]; +u8 connected_host[0x1 ]; +u8 vqos[0x1 ]; +u8 fast_response[0x1 ]; +u8 reserved_at_7[0x1 ]; +u8 local_port[0x8 ]; +u8 reserved_at_16[0x230 ]; +struct mlx5_ifc_ets_global_config_register_bits global_config; +}; +#define MLX5_MTUTC_TIMESTAMP_MODE_INTERNAL_TIMER 0#define MLX5_MTUTC_TIMESTAMP_MODE_REAL_TIME 1
drivers/net/mlx5/mlx5.h +2 -0
@@ -1271,6 +1271,8 @@ struct mlx5_dev_ctx_shared {void *devx_channel_lwm;struct rte_intr_handle *intr_handle_lwm;pthread_mutex_t lwm_config_lock; + uint32_t host_shaper_rate:8; + uint32_t lwm_triggered:1;/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
drivers/net/mlx5/mlx5_rx.c +104 -0
119 lines not on this page · raw message
drivers/net/mlx5/rte_pmd_mlx5.h +30 -0
@@ -109,6 +109,36 @@ int rte_pmd_mlx5_external_rx_queue_id_map(uint16_t port_id, uint16_t dpdk_idx,int rte_pmd_mlx5_external_rx_queue_id_unmap (uint16_t port_id,uint16_t dpdk_idx); +/** +* The rate of the host port shaper will be updated directly at the next +* available descriptor threshold event to the rate that comes with this flag set; +* set rate 0 to disable this rate update. +* Unset this flag to update the rate of the host port shaper directly in +* the API call; use rate 0 to disable the current shaper. +*/ +#define MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED 0 + +/** +* Configure a HW shaper to limit Tx rate for a host port. +* The configuration will affect all the ethdev ports belonging to +* the same rte_device. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] rate +* Unit is 100Mbps, setting the rate to 0 disables the shaper. +* @param[in] flags +* Host shaper flags. +* @return +* 0 : operation success. +* Otherwise: +* - ENOENT - no ibdev interface. +* - EBUSY - the register access unit is busy. +* - EIO - the register access command meets IO error. +*/ +__rte_experimental +int rte_pmd_mlx5_host_shaper_config(int port_id, uint8_t rate, uint32_t flags); + #ifdef __cplusplus }#endif
drivers/net/mlx5/version.map +2 -0
@@ -12,4 +12,6 @@ EXPERIMENTAL { # added in 22.03 rte_pmd_mlx5_external_rx_queue_id_map; rte_pmd_mlx5_external_rx_queue_id_unmap; + # added in 22.07 + rte_pmd_mlx5_host_shaper_config; };
Signature · 1 line
1.8.3.1
PATCH v8 1/6 net/mlx5: add LWM support for Rxq
In reply to Spike DuAdd lwm(Limit WaterMark) field to Rxq object which indicates the percentage of RX queue size used by HW to raise LWM event to the user. Allow LWM setting in modify_rq command.
Allow the LWM configuration dynamically by adding RDY2RDY state change.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_devx.c | 13 ++++++++++++- drivers/net/mlx5/mlx5_devx.h | 1 + drivers/net/mlx5/mlx5_rx.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1395,6 +1395,7 @@ enum mlx5_rxq_modify_type {MLX5_RXQ_MOD_RST2RDY ,/* modify state from reset to ready. */ MLX5_RXQ_MOD_RDY2ERR ,/* modify state from ready to error. */ MLX5_RXQ_MOD_RDY2RST ,/* modify state from ready to reset. */ + MLX5_RXQ_MOD_RDY2RDY, /* modify state from ready to ready. */ }; enum mlx5_txq_modify_type {
drivers/net/mlx5/mlx5_devx.c +12 -1
@@ -62,7 +62,7 @@* @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ -static int +int mlx5_devx_modify_rq (struct mlx5_rxq_priv *rxq,uint8_t type) {struct mlx5_devx_modify_rq_attr rq_attr;
@@ -76,6 +76,11 @@case MLX5_RXQ_MOD_RST2RDY : rq_attr.rq_state =MLX5_RQC_STATE_RST ; rq_attr.state =MLX5_RQC_STATE_RDY ; +if (rxq->lwm) { + rq_attr.modify_bitmask |= +MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM ; + rq_attr.lwm = rxq->lwm; + }break ;case MLX5_RXQ_MOD_RDY2ERR : rq_attr.rq_state =MLX5_RQC_STATE_RDY ;
@@ -85,6 +90,12 @@ rq_attr.rq_state =MLX5_RQC_STATE_RDY ; rq_attr.state =MLX5_RQC_STATE_RST ;break ; +case MLX5_RXQ_MOD_RDY2RDY : + rq_attr.rq_state =MLX5_RQC_STATE_RDY ; + rq_attr.state =MLX5_RQC_STATE_RDY ; + rq_attr.modify_bitmask |=MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM ; + rq_attr.lwm = rxq->lwm; +break ;default :break ; }
drivers/net/mlx5/mlx5_devx.h +1 -0
@@ -11,6 +11,7 @@int mlx5_txq_devx_modify (struct mlx5_txq_obj *obj,enum mlx5_txq_modify_type type,uint8_t dev_port);void mlx5_txq_devx_obj_release (struct mlx5_txq_obj *txq_obj); +int mlx5_devx_modify_rq (struct mlx5_rxq_priv *rxq,uint8_t type);extern struct mlx5_obj_ops devx_obj_ops;
drivers/net/mlx5/mlx5_rx.h +1 -0
@@ -175,6 +175,7 @@ struct mlx5_rxq_priv {struct mlx5_devx_rq devx_rq;struct rte_eth_hairpin_conf hairpin_conf;/* Hairpin configuration. */ uint32_t hairpin_status;/* Hairpin binding status. */ + uint32_t lwm:16; };/* External RX queue descriptor. */
Signature · 1 line
1.8.3.1
PATCH v8 3/6 net/mlx5: add LWM event handling support
In reply to Spike DuWhen LWM meets RQ WQE, the kernel driver raises an event to SW. Use devx event_channel to catch this and to notify the user. Allocate this channel per shared device.
The channel has a cookie that informs the specific event port and queue.
--- drivers/net/mlx5/mlx5.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5.h | 7 +++++ drivers/net/mlx5/mlx5_devx.c | 47 +++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.c | 33 ++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 7 +++++ 5 files changed, 160 insertions(+)
drivers/net/mlx5/mlx5.c +66 -0
@@ -9,6 +9,7 @@#include <stdint.h> #include <stdlib.h> #include <errno.h> +#include <fcntl.h> #include <rte_malloc.h> #include <ethdev_driver.h>
@@ -22,6 +23,7 @@#include <rte_eal_paging.h> #include <rte_alarm.h> #include <rte_cycles.h> +#include <rte_interrupts.h> #include <mlx5_glue.h> #include <mlx5_devx_cmds.h>
@@ -1525,6 +1527,69 @@ struct mlx5_dev_ctx_shared * }/** +* Create LWM event_channel and interrupt handle for shared device +* context. All rxqs sharing the device context share the event_channel. +* A callback is registered in interrupt thread to receive the LWM event. +* +* @param[in] priv +* Pointer to mlx5_priv instance. +* +* @return +* 0 on success, negative with rte_errno set. +*/ +int +mlx5_lwm_setup (struct mlx5_priv *priv) +{ +int fd_lwm; + +pthread_mutex_init (&priv->sh->lwm_config_lock,NULL ); + priv->sh->devx_channel_lwm =mlx5_os_devx_create_event_channel + (priv->sh->cdev->ctx, +MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA ); +if (!priv->sh->devx_channel_lwm) + goto err; + fd_lwm =mlx5_os_get_devx_channel_fd (priv->sh->devx_channel_lwm); + priv->sh->intr_handle_lwm =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , true, + fd_lwm, mlx5_dev_interrupt_handler_lwm, priv); +if (!priv->sh->intr_handle_lwm) + goto err; +return 0 ; +err: +if (priv->sh->devx_channel_lwm) { +mlx5_os_devx_destroy_event_channel + (priv->sh->devx_channel_lwm); + priv->sh->devx_channel_lwm =NULL ; + } +pthread_mutex_destroy (&priv->sh->lwm_config_lock); +return -rte_errno; +} + +/** +* Destroy LWM event_channel and interrupt handle for shared device +* context before free this context. The interrupt handler is also +* unregistered. +* +* @param[in] sh +* Pointer to shared device context. +*/ +void +mlx5_lwm_unset (struct mlx5_dev_ctx_shared *sh) +{ +if (sh->intr_handle_lwm) { +mlx5_os_interrupt_handler_destroy (sh->intr_handle_lwm, + mlx5_dev_interrupt_handler_lwm, (void *)-1 ); + sh->intr_handle_lwm =NULL ; + } +if (sh->devx_channel_lwm) { +mlx5_os_devx_destroy_event_channel + (sh->devx_channel_lwm); + sh->devx_channel_lwm =NULL ; + } +pthread_mutex_destroy (&sh->lwm_config_lock); +} + +/** * Free shared IB device context. Decrement counter and if zero free * all allocated resources and close handles. *
@@ -1601,6 +1666,7 @@ struct mlx5_dev_ctx_shared *claim_zero (mlx5_devx_cmd_destroy (sh->td));MLX5_ASSERT (sh->geneve_tlv_option_resource ==NULL );pthread_mutex_destroy (&sh->txpp.mutex); +mlx5_lwm_unset (sh);mlx5_free (sh);return ; exit:
drivers/net/mlx5/mlx5.h +7 -0
@@ -1268,6 +1268,9 @@ struct mlx5_dev_ctx_shared {struct mlx5_lb_ctx self_lb;/* QP to enable self loopback for Devx. */ unsigned int flow_max_priority;enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM ]; +void *devx_channel_lwm; +struct rte_intr_handle *intr_handle_lwm; +pthread_mutex_t lwm_config_lock;/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1405,6 +1408,7 @@ enum mlx5_txq_modify_type { };struct mlx5_rxq_priv ; +struct mlx5_priv ;/* HW objects operations structure. */ struct mlx5_obj_ops {
@@ -1413,6 +1417,7 @@ struct mlx5_obj_ops {int (*rxq_event_get)(struct mlx5_rxq_obj *rxq_obj);int (*rxq_obj_modify)(struct mlx5_rxq_priv *rxq,uint8_t type);void (*rxq_obj_release)(struct mlx5_rxq_priv *rxq); +int (*rxq_event_get_lwm)(struct mlx5_priv *priv,int *rxq_idx,int *port_id);int (*ind_table_new)(struct rte_eth_dev *dev,const unsigned int log_n,struct mlx5_ind_table_obj *ind_tbl); int (*ind_table_modify)(struct rte_eth_dev *dev,
@@ -1603,6 +1608,8 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,bool mlx5_is_hpf (struct rte_eth_dev *dev);bool mlx5_is_sf_repr (struct rte_eth_dev *dev);void mlx5_age_event_prepare (struct mlx5_dev_ctx_shared *sh); +int mlx5_lwm_setup (struct mlx5_priv *priv); +void mlx5_lwm_unset (struct mlx5_dev_ctx_shared *sh);/* Macro to iterate over all valid ports for mlx5 driver. */ #define MLX5_ETH_FOREACH_DEV (port_id, dev) \
drivers/net/mlx5/mlx5_devx.c +47 -0
59 lines not on this page · raw message
drivers/net/mlx5/mlx5_rx.c +33 -0
@@ -1187,3 +1187,36 @@ int mlx5_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) {return -ENOTSUP ; } + +/** +* Rte interrupt handler for LWM event. +* It first checks if the event arrives, if so process the callback for +* RTE_ETH_EVENT_RX_LWM. +* +* @param args +* Generic pointer to mlx5_priv. +*/ +void +mlx5_dev_interrupt_handler_lwm (void *args) +{ +struct mlx5_priv *priv = args; +struct mlx5_rxq_priv *rxq; +struct rte_eth_dev *dev; +int ret, rxq_idx =0 , port_id =0 ; + + ret = priv->obj_ops.rxq_event_get_lwm (priv, &rxq_idx, &port_id); +if (unlikely (ret <0 )) { +DRV_LOG (WARNING ,"Cannot get LWM event context." ); +return ; + } +DRV_LOG (INFO ,"%s get LWM event, port_id:%d rxq_id:%d." , __func__, + port_id, rxq_idx); + dev = &rte_eth_devices[port_id]; + rxq =mlx5_rxq_get (dev, rxq_idx); +if (rxq) { +pthread_mutex_lock (&priv->sh->lwm_config_lock); + rxq->lwm_event_pending =1 ; +pthread_mutex_unlock (&priv->sh->lwm_config_lock); + } +rte_eth_dev_callback_process (dev,RTE_ETH_EVENT_RX_AVAIL_THRESH ,NULL ); +}
drivers/net/mlx5/mlx5_rx.h +7 -0
@@ -176,6 +176,7 @@ struct mlx5_rxq_priv {struct rte_eth_hairpin_conf hairpin_conf;/* Hairpin configuration. */ uint32_t hairpin_status;/* Hairpin binding status. */ uint32_t lwm:16; + uint32_t lwm_event_pending:1; };/* External RX queue descriptor. */
@@ -295,6 +296,7 @@ void mlx5_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,int mlx5_rx_burst_mode_get (struct rte_eth_dev *dev,uint16_t rx_queue_id,struct rte_eth_burst_mode *mode);int mlx5_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc); +void mlx5_dev_interrupt_handler_lwm (void *args);/* Vectorized version of mlx5_rx.c */ int mlx5_rxq_check_vec_support (struct mlx5_rxq_data *rxq_data);
@@ -675,4 +677,9 @@ uint16_t mlx5_rx_burst_mprq_vec(void *dpdk_rxq, struct rte_mbuf **pkts, return !!__atomic_load_n(&rxq->refcnt, __ATOMIC_RELAXED); } +#define LWM_COOKIE_RXQID_OFFSET 0 +#define LWM_COOKIE_RXQID_MASK 0xffff +#define LWM_COOKIE_PORTID_OFFSET 16 +#define LWM_COOKIE_PORTID_MASK 0xffff +#endif /* RTE_PMD_MLX5_RX_H_ */
Signature · 1 line
1.8.3.1
PATCH v8 4/6 net/mlx5: support Rx queue based available descriptor threshold
In reply to Spike DuAdd mlx5 specific available descriptor threshold configuration and query handler.
In mlx5 PMD, available descriptor threshold is also called LWM(limit watermark).
While the Rx queue fullness reaches the LWM limit, the driver catches an HW event and invokes the user callback.
The query handler finds the next RX queue with pending LWM event if any, starting from the given RX queue index.
--- doc/guides/nics/mlx5.rst | 12 +++ doc/guides/rel_notes/release_22_07.rst | 1 + drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/mlx5.c | 2 + drivers/net/mlx5/mlx5_rx.c | 151 +++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 5 ++ 6 files changed, 172 insertions(+)
doc/guides/nics/mlx5.rst +12 -0
@@ -93,6 +93,7 @@ Features - Connection tracking. - Sub-Function representors. - Sub-Function. +- Rx queue available descriptor threshold configuration. Limitations
@@ -520,6 +521,9 @@ Limitations - The NIC egress flow rules on representor port are not supported. +- Available descriptor threshold: + + - Doesn't support shared Rx queue and Hairpin Rx queue. Statistics ----------
@@ -1680,3 +1684,11 @@ The procedure below is an example of using a ConnectX-5 adapter card (pf0) with #. For each VF PCIe, using the following command to bind the driver:: $ echo "0000:82:00.2" >> /sys/bus/pci/drivers/mlx5_core/bind + +Available descriptor threshold introduction +------------------------------------------- + +Available descriptor threshold is a per Rx queue attribute, it should be configured as +a percentage of the Rx queue size. +When Rx queue available descriptors for hardware are below the threshold, an event is sent to PMD. +
doc/guides/rel_notes/release_22_07.rst +1 -0
@@ -89,6 +89,7 @@ New Features * Added support for promiscuous mode on Windows. * Added support for MTU on Windows. * Added matching and RSS on IPsec ESP. + * Added Rx queue available descriptor threshold support. * **Updated Marvell cnxk crypto driver.**
drivers/common/mlx5/mlx5_prm.h +1 -0
@@ -3293,6 +3293,7 @@ struct mlx5_aso_wqe {enum {MLX5_EVENT_TYPE_OBJECT_CHANGE =0x27 , +MLX5_EVENT_TYPE_SRQ_LIMIT_REACHED =0x14 , };enum {
drivers/net/mlx5/mlx5.c +2 -0
@@ -2071,6 +2071,8 @@ struct mlx5_dev_ctx_shared * .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get, .vlan_filter_set = mlx5_vlan_filter_set, .rx_queue_setup = mlx5_rx_queue_setup, + .rx_queue_avail_thresh_set = mlx5_rx_queue_lwm_set, + .rx_queue_avail_thresh_query = mlx5_rx_queue_lwm_query, .rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup, .tx_queue_setup = mlx5_tx_queue_setup, .tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
drivers/net/mlx5/mlx5_rx.c +151 -0
184 lines not on this page · raw message
drivers/net/mlx5/mlx5_rx.h +5 -0
@@ -177,6 +177,7 @@ struct mlx5_rxq_priv {uint32_t hairpin_status;/* Hairpin binding status. */ uint32_t lwm:16; uint32_t lwm_event_pending:1; + uint32_t lwm_devx_subscribed:1; };/* External RX queue descriptor. */
@@ -297,6 +298,10 @@ int mlx5_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t rx_queue_id, struct rte_eth_burst_mode *mode);int mlx5_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc);void mlx5_dev_interrupt_handler_lwm (void *args); +int mlx5_rx_queue_lwm_set (struct rte_eth_dev *dev,uint16_t rx_queue_id, +uint8_t lwm); +int mlx5_rx_queue_lwm_query (struct rte_eth_dev *dev,uint16_t *rx_queue_id, +uint8_t *lwm);/* Vectorized version of mlx5_rx.c */ int mlx5_rxq_check_vec_support (struct mlx5_rxq_data *rxq_data);
Signature · 1 line
1.8.3.1
PATCH v8 6/6 app/testpmd: add Host Shaper command
In reply to Spike DuAdd command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id> host_shaper avail_thresh_triggered <0|1> rate
<rate_num>
- Example commands:
To enable avail_thresh_triggered on port 1 and disable current host shaper:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0
To disable avail_thresh_triggered and current host shaper on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0
The rate unit is 100Mbps.
To disable avail_thresh_triggered and configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50
Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
--- app/test-pmd/testpmd.c | 7 ++ doc/guides/nics/mlx5.rst | 46 +++++++++ drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5_testpmd.c | 205 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++++ 5 files changed, 288 insertions(+) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
app/test-pmd/testpmd.c +7 -0
@@ -69,6 +69,9 @@#ifdef RTE_NET_BOND #include <rte_eth_bond.h> #endif +#ifdef RTE_NET_MLX5 +#include "mlx5_testpmd.h" +#endif #include "testpmd.h"
@@ -3659,6 +3662,10 @@ struct pmd_test_command {break ;printf ("Received avail_thresh event, port:%d rxq_id:%d\n" , port_id, rxq_id); + +#ifdef RTE_NET_MLX5 +mlx5_test_avail_thresh_event_handler (port_id, rxq_id); +#endif }break ;default :
doc/guides/nics/mlx5.rst +46 -0
49 lines not on this page · raw message
drivers/net/mlx5/meson.build +4 -0
@@ -68,4 +68,8 @@ if get_option('buildtype').contains('debug') else cflags += [ '-UPEDANTIC' ] endif + +testpmd_sources += files('mlx5_testpmd.c') +testpmd_drivers_deps += 'net_mlx5' + subdir(exec_env)
drivers/net/mlx5/mlx5_testpmd.c new file +205 -0
205 lines not on this page · raw message
drivers/net/mlx5/mlx5_testpmd.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 6WIND S.A. +* Copyright 2021 Mellanox Technologies, Ltd +*/ + +#ifndef RTE_PMD_MLX5_TEST_H_ +#define RTE_PMD_MLX5_TEST_H_ + +#include <cmdline_parse.h> +#include <cmdline_parse_num.h> +#include <cmdline_parse_string.h> + +/** +* RTE_ETH_EVENT_RX_AVAIL_THRESH handler sample code. +* It's called in testpmd, the work flow here is delay a while until +* RX queueu is empty, then disable host shaper. +* +* @param[in] port_id +* Port identifier. +* @param[in] rxq_id +* Rx queue identifier. +*/ +void +mlx5_test_avail_thresh_event_handler (uint16_t port_id,uint16_t rxq_id); + +#endif
Signature · 1 line
1.8.3.1
PATCH v9 1/6 net/mlx5: add LWM support for Rxq
In reply to Spike DuAdd lwm(Limit WaterMark) field to Rxq object which indicates the percentage of RX queue size used by HW to raise LWM event to the user. Allow LWM setting in modify_rq command.
Allow the LWM configuration dynamically by adding RDY2RDY state change.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_devx.c | 13 ++++++++++++- drivers/net/mlx5/mlx5_devx.h | 1 + drivers/net/mlx5/mlx5_rx.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1395,6 +1395,7 @@ enum mlx5_rxq_modify_type {MLX5_RXQ_MOD_RST2RDY ,/* modify state from reset to ready. */ MLX5_RXQ_MOD_RDY2ERR ,/* modify state from ready to error. */ MLX5_RXQ_MOD_RDY2RST ,/* modify state from ready to reset. */ + MLX5_RXQ_MOD_RDY2RDY, /* modify state from ready to ready. */ }; enum mlx5_txq_modify_type {
drivers/net/mlx5/mlx5_devx.c +12 -1
@@ -62,7 +62,7 @@* @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ -static int +int mlx5_devx_modify_rq (struct mlx5_rxq_priv *rxq,uint8_t type) {struct mlx5_devx_modify_rq_attr rq_attr;
@@ -76,6 +76,11 @@case MLX5_RXQ_MOD_RST2RDY : rq_attr.rq_state =MLX5_RQC_STATE_RST ; rq_attr.state =MLX5_RQC_STATE_RDY ; +if (rxq->lwm) { + rq_attr.modify_bitmask |= +MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM ; + rq_attr.lwm = rxq->lwm; + }break ;case MLX5_RXQ_MOD_RDY2ERR : rq_attr.rq_state =MLX5_RQC_STATE_RDY ;
@@ -85,6 +90,12 @@ rq_attr.rq_state =MLX5_RQC_STATE_RDY ; rq_attr.state =MLX5_RQC_STATE_RST ;break ; +case MLX5_RXQ_MOD_RDY2RDY : + rq_attr.rq_state =MLX5_RQC_STATE_RDY ; + rq_attr.state =MLX5_RQC_STATE_RDY ; + rq_attr.modify_bitmask |=MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM ; + rq_attr.lwm = rxq->lwm; +break ;default :break ; }
drivers/net/mlx5/mlx5_devx.h +1 -0
@@ -11,6 +11,7 @@int mlx5_txq_devx_modify (struct mlx5_txq_obj *obj,enum mlx5_txq_modify_type type,uint8_t dev_port);void mlx5_txq_devx_obj_release (struct mlx5_txq_obj *txq_obj); +int mlx5_devx_modify_rq (struct mlx5_rxq_priv *rxq,uint8_t type);extern struct mlx5_obj_ops devx_obj_ops;
drivers/net/mlx5/mlx5_rx.h +1 -0
@@ -175,6 +175,7 @@ struct mlx5_rxq_priv {struct mlx5_devx_rq devx_rq;struct rte_eth_hairpin_conf hairpin_conf;/* Hairpin configuration. */ uint32_t hairpin_status;/* Hairpin binding status. */ + uint32_t lwm:16; };/* External RX queue descriptor. */
Signature · 1 line
1.8.3.1
v9 cover introduce per-queue available descriptor threshold and host shaper
In reply to Spike Duavailable descriptor threshold(ADT for short) is per RX queue attribute, when RX queue available descriptors for HW is below ADT, HW sends an event to application. Host shaper can configure shaper rate and avail_thresh-triggered for a host port.
The shaper limits the rate of traffic from host port to embedded ARM rx port on Nvidia BlueField 2 NIC.
If avail_thresh-triggered is enabled, a 100Mbps shaper is enabled automatically when one of the host port's Rx queues receives available descriptor threshold event.
These two features can combine to control traffic from host port to wire port for BlueField 2 NIC.
The traffic flows from host to embedded ARM, then to the physical port.
The work flow is on the ARM system, configure available descriptor threshold to RX queue and enable avail_thresh-triggered flag in host shaper, after receiving available descriptor threshold event, delay a while until RX queue is empty , then disable the shaper. We recycle this work flow to reduce RX queue drops on ARM system.
Add new libethdev API to set available descriptor threshold, add rte event RTE_ETH_EVENT_RX_AVAIL_THRESH to handle available descriptor threshold event. For host shaper, because it doesn't align to existing DPDK framework and is specific to Nvidia NIC, use PMD private API.
For integration with testpmd, put the private cmdline function and available descriptor threshold event handler in mlx5 PMD directory by adding a new file mlx5_testpmd.c. Follow David Marchand's driver specific commands framework to add mlx5 specific commands.
Spike Du (6):
net/mlx5: add LWM support for Rxq
common/mlx5: share interrupt management
net/mlx5: add LWM event handling support
net/mlx5: support Rx queue based available descriptor threshold net/mlx5: add private API to config host port shaper app/testpmd: add Host Shaper command
app/test-pmd/testpmd.c | 7 + doc/guides/nics/mlx5.rst | 93 +++++++++ doc/guides/rel_notes/release_22_07.rst | 2 + drivers/common/mlx5/linux/meson.build | 13 ++ drivers/common/mlx5/linux/mlx5_common_os.c | 131 ++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 11 + drivers/common/mlx5/mlx5_prm.h | 26 +++ drivers/common/mlx5/version.map | 2 + drivers/common/mlx5/windows/mlx5_common_os.h | 24 +++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 71 ------- drivers/net/mlx5/linux/mlx5_os.c | 132 +++--------- drivers/net/mlx5/linux/mlx5_socket.c | 53 +---- drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5.c | 68 +++++++ drivers/net/mlx5/mlx5.h | 12 +- drivers/net/mlx5/mlx5_devx.c | 60 +++++- drivers/net/mlx5/mlx5_devx.h | 1 + drivers/net/mlx5/mlx5_rx.c | 288 +++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 13 ++ drivers/net/mlx5/mlx5_testpmd.c | 205 +++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++ drivers/net/mlx5/mlx5_txpp.c | 28 +-- drivers/net/mlx5/rte_pmd_mlx5.h | 30 +++ drivers/net/mlx5/version.map | 2 + drivers/net/mlx5/windows/mlx5_ethdev_os.c | 22 -- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 48 +---- 26 files changed, 1064 insertions(+), 308 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
Signature · 1 line
1.8.3.1
PATCH v9 2/6 common/mlx5: share interrupt management
There are many duplicate code of creating and initializing rte_intr_handle. Add a new mlx5_os API to do this, replace all PMD related code with this API.
--- drivers/common/mlx5/linux/mlx5_common_os.c | 131 ++++++++++++++++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 11 +++ drivers/common/mlx5/version.map | 2 + drivers/common/mlx5/windows/mlx5_common_os.h | 24 +++++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 71 -------------- drivers/net/mlx5/linux/mlx5_os.c | 132 ++++++--------------------- drivers/net/mlx5/linux/mlx5_socket.c | 53 ++--------- drivers/net/mlx5/mlx5.h | 2 - drivers/net/mlx5/mlx5_txpp.c | 28 ++---- drivers/net/mlx5/windows/mlx5_ethdev_os.c | 22 ----- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 48 ++-------- 11 files changed, 217 insertions(+), 307 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.c +131 -0
@@ -11,6 +11,7 @@#endif #include <dirent.h> #include <net/if.h> +#include <fcntl.h> #include <rte_errno.h> #include <rte_string_fns.h>
@@ -964,3 +965,133 @@claim_zero (mlx5_glue->dereg_mr (pmd_mr->obj));memset (pmd_mr,0 ,sizeof (*pmd_mr)); } + +/** +* Rte_intr_handle create and init helper. +* +* @param[in] mode +* interrupt instance can be shared between primary and secondary +* processes or not. +* @param[in] set_fd_nonblock +* Whether to set fd to O_NONBLOCK. +* @param[in] fd +* Fd to set in created intr_handle. +* @param[in] cb +* Callback to register for intr_handle. +* @param[in] cb_arg +* Callback argument for cb. +* +* @return +* - Interrupt handle on success. +* - NULL on failure, with rte_errno set. +*/ +struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg) +{ +struct rte_intr_handle *tmp_intr_handle; +int ret, flags; + + tmp_intr_handle =rte_intr_instance_alloc (mode); +if (!tmp_intr_handle) { + rte_errno =ENOMEM ; + goto err; + } +if (set_fd_nonblock) { + flags =fcntl (fd,F_GETFL ); + ret =fcntl (fd,F_SETFL , flags |O_NONBLOCK ); +if (ret) { + rte_errno = errno; + goto err; + } + } + ret =rte_intr_fd_set (tmp_intr_handle, fd); +if (ret) + goto err; + ret =rte_intr_type_set (tmp_intr_handle,RTE_INTR_HANDLE_EXT ); +if (ret) + goto err; + ret =rte_intr_callback_register (tmp_intr_handle, cb, cb_arg); +if (ret) { + rte_errno = -ret; + goto err; + } +return tmp_intr_handle; +err: +if (tmp_intr_handle) +rte_intr_instance_free (tmp_intr_handle); +return NULL ; +} + +/* Safe unregistration for interrupt callback. */ +static void +mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, +rte_intr_callback_fn cb_fn,void *cb_arg) +{ +uint64_t twait =0 ; +uint64_t start =0 ; + +do { +int ret; + + ret =rte_intr_callback_unregister (handle, cb_fn, cb_arg); +if (ret >=0 ) +return ; +if (ret != -EAGAIN ) { +DRV_LOG (INFO ,"failed to unregister interrupt" +" handler (error: %d)" , ret); +MLX5_ASSERT (false); +return ; + } +if (twait) { +struct timespec onems; + +/* Wait one millisecond and try again. */ + onems.tv_sec =0 ; + onems.tv_nsec =NS_PER_S /MS_PER_S ; +nanosleep (&onems,0 ); +/* Check whether one second elapsed. */ +if ((rte_get_timer_cycles () - start) <= twait) +continue ; + }else { +/* +* We get the amount of timer ticks for one second. +* If this amount elapsed it means we spent one +* second in waiting. This branch is executed once +* on first iteration. +*/ + twait =rte_get_timer_hz (); +MLX5_ASSERT (twait); + } +/* +* Timeout elapsed, show message (once a second) and retry. +* We have no other acceptable option here, if we ignore +* the unregistering return code the handler will not +* be unregistered, fd will be closed and we may get the +* crush. Hanging and messaging in the loop seems not to be +* the worst choice. +*/ +DRV_LOG (INFO ,"Retrying to unregister interrupt handler" ); + start =rte_get_timer_cycles (); + }while (true); +} + +/** +* Rte_intr_handle destroy helper. +* +* @param[in] intr_handle +* Rte_intr_handle to destroy. +* @param[in] cb +* Callback which is registered to intr_handle. +* @param[in] cb_arg +* Callback argument for cb. +* +*/ +void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg) +{ +if (rte_intr_fd_get (intr_handle) >=0 ) +mlx5_intr_callback_unregister (intr_handle, cb, cb_arg); +rte_intr_instance_free (intr_handle); +}
drivers/common/mlx5/linux/mlx5_common_os.h +11 -0
@@ -15,6 +15,7 @@#include <rte_log.h> #include <rte_kvargs.h> #include <rte_devargs.h> +#include <rte_interrupts.h> #include "mlx5_autoconf.h" #include "mlx5_glue.h"
@@ -299,4 +300,14 @@int mlx5_get_device_guid (const struct rte_pci_addr *dev,uint8_t *guid,size_t len); +__rte_internal +struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg); + +__rte_internal +void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg); +#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/version.map +2 -0
@@ -153,5 +153,7 @@ INTERNAL { mlx5_mr_mempool2mr_bh; mlx5_mr_mempool_populate_cache; + mlx5_os_interrupt_handler_create; # WINDOWS_NO_EXPORT + mlx5_os_interrupt_handler_destroy; # WINDOWS_NO_EXPORT local: *; };
drivers/common/mlx5/windows/mlx5_common_os.h +24 -0
@@ -9,6 +9,7 @@#include <sys/types.h> #include <rte_errno.h> +#include <rte_interrupts.h> #include "mlx5_autoconf.h" #include "mlx5_glue.h"
@@ -253,4 +254,27 @@__rte_internal int mlx5_os_umem_dereg(void *pumem); +static inline struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg) +{ + (void )mode; + (void )set_fd_nonblock; + (void )fd; + (void )cb; + (void )cb_arg; + rte_errno =ENOTSUP ; +return NULL ; +} + +static inline void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg) +{ + (void )intr_handle; + (void )cb; + (void )cb_arg; +} + +#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/net/mlx5/linux/mlx5_ethdev_os.c +0 -71
77 lines not on this page · raw message
drivers/net/mlx5/linux/mlx5_os.c +29 -103
169 lines not on this page · raw message
drivers/net/mlx5/linux/mlx5_socket.c +6 -47
71 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +0 -2
@@ -1682,8 +1682,6 @@ int mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info);void mlx5_translate_port_name (const char *port_name_in,struct mlx5_switch_info *port_info_out); -void mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, -rte_intr_callback_fn cb_fn,void *cb_arg);int mlx5_sysfs_bond_info (unsigned int pf_ifindex,unsigned int *ifindex,char *ifname); int mlx5_get_module_info(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_txpp.c +7 -21
@@ -741,11 +741,8 @@static void mlx5_txpp_stop_service (struct mlx5_dev_ctx_shared *sh) { -if (!rte_intr_fd_get (sh->txpp.intr_handle)) -return ; -mlx5_intr_callback_unregister (sh->txpp.intr_handle, - mlx5_txpp_interrupt_handler, sh); -rte_intr_instance_free (sh->txpp.intr_handle); +mlx5_os_interrupt_handler_destroy (sh->txpp.intr_handle, + mlx5_txpp_interrupt_handler, sh); }/* Attach interrupt handler and fires first request to Rearm Queue. */
@@ -769,23 +766,12 @@ rte_errno = errno;return -rte_errno; } - sh->txpp.intr_handle = -rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_SHARED ); -if (sh->txpp.intr_handle ==NULL ) { -DRV_LOG (ERR ,"Fail to allocate intr_handle" ); -return -ENOMEM ; - } fd =mlx5_os_get_devx_channel_fd (sh->txpp.echan); -if (rte_intr_fd_set (sh->txpp.intr_handle, fd)) -return -rte_errno; - -if (rte_intr_type_set (sh->txpp.intr_handle,RTE_INTR_HANDLE_EXT )) -return -rte_errno; - -if (rte_intr_callback_register (sh->txpp.intr_handle, - mlx5_txpp_interrupt_handler, sh)) { -rte_intr_fd_set (sh->txpp.intr_handle,0 ); -DRV_LOG (ERR ,"Failed to register CQE interrupt %d." , rte_errno); + sh->txpp.intr_handle =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , false, + fd, mlx5_txpp_interrupt_handler, sh); +if (!sh->txpp.intr_handle) { +DRV_LOG (ERR ,"Fail to allocate intr_handle" );return -rte_errno; }/* Subscribe CQ event to the event channel controlled by the driver. */
drivers/net/mlx5/windows/mlx5_ethdev_os.c +0 -22
@@ -140,28 +140,6 @@return 0 ; } -/* -* Unregister callback handler safely. The handler may be active -* while we are trying to unregister it, in this case code -EAGAIN -* is returned by rte_intr_callback_unregister(). This routine checks -* the return code and tries to unregister handler again. -* -* @param handle -* interrupt handle -* @param cb_fn -* pointer to callback routine -* @cb_arg -* opaque callback parameter -*/ -void -mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, -rte_intr_callback_fn cb_fn,void *cb_arg) -{ -RTE_SET_USED (handle); -RTE_SET_USED (cb_fn); -RTE_SET_USED (cb_arg); -} -/** * DPDK callback to get flow control status. *
drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +7 -41
64 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v9 3/6 net/mlx5: add LWM event handling support
In reply to Spike DuWhen LWM meets RQ WQE, the kernel driver raises an event to SW. Use devx event_channel to catch this and to notify the user. Allocate this channel per shared device.
The channel has a cookie that informs the specific event port and queue.
--- drivers/net/mlx5/mlx5.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5.h | 7 +++++ drivers/net/mlx5/mlx5_devx.c | 47 +++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.c | 33 ++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 7 +++++ 5 files changed, 160 insertions(+)
drivers/net/mlx5/mlx5.c +66 -0
@@ -9,6 +9,7 @@#include <stdint.h> #include <stdlib.h> #include <errno.h> +#include <fcntl.h> #include <rte_malloc.h> #include <ethdev_driver.h>
@@ -22,6 +23,7 @@#include <rte_eal_paging.h> #include <rte_alarm.h> #include <rte_cycles.h> +#include <rte_interrupts.h> #include <mlx5_glue.h> #include <mlx5_devx_cmds.h>
@@ -1525,6 +1527,69 @@ struct mlx5_dev_ctx_shared * }/** +* Create LWM event_channel and interrupt handle for shared device +* context. All rxqs sharing the device context share the event_channel. +* A callback is registered in interrupt thread to receive the LWM event. +* +* @param[in] priv +* Pointer to mlx5_priv instance. +* +* @return +* 0 on success, negative with rte_errno set. +*/ +int +mlx5_lwm_setup (struct mlx5_priv *priv) +{ +int fd_lwm; + +pthread_mutex_init (&priv->sh->lwm_config_lock,NULL ); + priv->sh->devx_channel_lwm =mlx5_os_devx_create_event_channel + (priv->sh->cdev->ctx, +MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA ); +if (!priv->sh->devx_channel_lwm) + goto err; + fd_lwm =mlx5_os_get_devx_channel_fd (priv->sh->devx_channel_lwm); + priv->sh->intr_handle_lwm =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , true, + fd_lwm, mlx5_dev_interrupt_handler_lwm, priv); +if (!priv->sh->intr_handle_lwm) + goto err; +return 0 ; +err: +if (priv->sh->devx_channel_lwm) { +mlx5_os_devx_destroy_event_channel + (priv->sh->devx_channel_lwm); + priv->sh->devx_channel_lwm =NULL ; + } +pthread_mutex_destroy (&priv->sh->lwm_config_lock); +return -rte_errno; +} + +/** +* Destroy LWM event_channel and interrupt handle for shared device +* context before free this context. The interrupt handler is also +* unregistered. +* +* @param[in] sh +* Pointer to shared device context. +*/ +void +mlx5_lwm_unset (struct mlx5_dev_ctx_shared *sh) +{ +if (sh->intr_handle_lwm) { +mlx5_os_interrupt_handler_destroy (sh->intr_handle_lwm, + mlx5_dev_interrupt_handler_lwm, (void *)-1 ); + sh->intr_handle_lwm =NULL ; + } +if (sh->devx_channel_lwm) { +mlx5_os_devx_destroy_event_channel + (sh->devx_channel_lwm); + sh->devx_channel_lwm =NULL ; + } +pthread_mutex_destroy (&sh->lwm_config_lock); +} + +/** * Free shared IB device context. Decrement counter and if zero free * all allocated resources and close handles. *
@@ -1601,6 +1666,7 @@ struct mlx5_dev_ctx_shared *claim_zero (mlx5_devx_cmd_destroy (sh->td));MLX5_ASSERT (sh->geneve_tlv_option_resource ==NULL );pthread_mutex_destroy (&sh->txpp.mutex); +mlx5_lwm_unset (sh);mlx5_free (sh);return ; exit:
drivers/net/mlx5/mlx5.h +7 -0
@@ -1268,6 +1268,9 @@ struct mlx5_dev_ctx_shared {struct mlx5_lb_ctx self_lb;/* QP to enable self loopback for Devx. */ unsigned int flow_max_priority;enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM ]; +void *devx_channel_lwm; +struct rte_intr_handle *intr_handle_lwm; +pthread_mutex_t lwm_config_lock;/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1405,6 +1408,7 @@ enum mlx5_txq_modify_type { };struct mlx5_rxq_priv ; +struct mlx5_priv ;/* HW objects operations structure. */ struct mlx5_obj_ops {
@@ -1413,6 +1417,7 @@ struct mlx5_obj_ops {int (*rxq_event_get)(struct mlx5_rxq_obj *rxq_obj);int (*rxq_obj_modify)(struct mlx5_rxq_priv *rxq,uint8_t type);void (*rxq_obj_release)(struct mlx5_rxq_priv *rxq); +int (*rxq_event_get_lwm)(struct mlx5_priv *priv,int *rxq_idx,int *port_id);int (*ind_table_new)(struct rte_eth_dev *dev,const unsigned int log_n,struct mlx5_ind_table_obj *ind_tbl); int (*ind_table_modify)(struct rte_eth_dev *dev,
@@ -1603,6 +1608,8 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,bool mlx5_is_hpf (struct rte_eth_dev *dev);bool mlx5_is_sf_repr (struct rte_eth_dev *dev);void mlx5_age_event_prepare (struct mlx5_dev_ctx_shared *sh); +int mlx5_lwm_setup (struct mlx5_priv *priv); +void mlx5_lwm_unset (struct mlx5_dev_ctx_shared *sh);/* Macro to iterate over all valid ports for mlx5 driver. */ #define MLX5_ETH_FOREACH_DEV (port_id, dev) \
drivers/net/mlx5/mlx5_devx.c +47 -0
59 lines not on this page · raw message
drivers/net/mlx5/mlx5_rx.c +33 -0
@@ -1187,3 +1187,36 @@ int mlx5_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) {return -ENOTSUP ; } + +/** +* Rte interrupt handler for LWM event. +* It first checks if the event arrives, if so process the callback for +* RTE_ETH_EVENT_RX_LWM. +* +* @param args +* Generic pointer to mlx5_priv. +*/ +void +mlx5_dev_interrupt_handler_lwm (void *args) +{ +struct mlx5_priv *priv = args; +struct mlx5_rxq_priv *rxq; +struct rte_eth_dev *dev; +int ret, rxq_idx =0 , port_id =0 ; + + ret = priv->obj_ops.rxq_event_get_lwm (priv, &rxq_idx, &port_id); +if (unlikely (ret <0 )) { +DRV_LOG (WARNING ,"Cannot get LWM event context." ); +return ; + } +DRV_LOG (INFO ,"%s get LWM event, port_id:%d rxq_id:%d." , __func__, + port_id, rxq_idx); + dev = &rte_eth_devices[port_id]; + rxq =mlx5_rxq_get (dev, rxq_idx); +if (rxq) { +pthread_mutex_lock (&priv->sh->lwm_config_lock); + rxq->lwm_event_pending =1 ; +pthread_mutex_unlock (&priv->sh->lwm_config_lock); + } +rte_eth_dev_callback_process (dev,RTE_ETH_EVENT_RX_AVAIL_THRESH ,NULL ); +}
drivers/net/mlx5/mlx5_rx.h +7 -0
@@ -176,6 +176,7 @@ struct mlx5_rxq_priv {struct rte_eth_hairpin_conf hairpin_conf;/* Hairpin configuration. */ uint32_t hairpin_status;/* Hairpin binding status. */ uint32_t lwm:16; + uint32_t lwm_event_pending:1; };/* External RX queue descriptor. */
@@ -295,6 +296,7 @@ void mlx5_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,int mlx5_rx_burst_mode_get (struct rte_eth_dev *dev,uint16_t rx_queue_id,struct rte_eth_burst_mode *mode);int mlx5_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc); +void mlx5_dev_interrupt_handler_lwm (void *args);/* Vectorized version of mlx5_rx.c */ int mlx5_rxq_check_vec_support (struct mlx5_rxq_data *rxq_data);
@@ -675,4 +677,9 @@ uint16_t mlx5_rx_burst_mprq_vec(void *dpdk_rxq, struct rte_mbuf **pkts, return !!__atomic_load_n(&rxq->refcnt, __ATOMIC_RELAXED); } +#define LWM_COOKIE_RXQID_OFFSET 0 +#define LWM_COOKIE_RXQID_MASK 0xffff +#define LWM_COOKIE_PORTID_OFFSET 16 +#define LWM_COOKIE_PORTID_MASK 0xffff +#endif /* RTE_PMD_MLX5_RX_H_ */
Signature · 1 line
1.8.3.1
PATCH v9 4/6 net/mlx5: support Rx queue based available descriptor threshold
In reply to Spike DuAdd mlx5 specific available descriptor threshold configuration and query handler.
In mlx5 PMD, available descriptor threshold is also called LWM(limit watermark).
While the Rx queue fullness reaches the LWM limit, the driver catches an HW event and invokes the user callback.
The query handler finds the next RX queue with pending LWM event if any, starting from the given RX queue index.
--- doc/guides/nics/mlx5.rst | 12 +++ doc/guides/rel_notes/release_22_07.rst | 1 + drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/mlx5.c | 2 + drivers/net/mlx5/mlx5_rx.c | 151 +++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 5 ++ 6 files changed, 172 insertions(+)
doc/guides/nics/mlx5.rst +12 -0
@@ -93,6 +93,7 @@ Features - Connection tracking. - Sub-Function representors. - Sub-Function. +- Rx queue available descriptor threshold configuration. Limitations
@@ -520,6 +521,9 @@ Limitations - The NIC egress flow rules on representor port are not supported. +- Available descriptor threshold: + + - Doesn't support shared Rx queue and Hairpin Rx queue. Statistics ----------
@@ -1680,3 +1684,11 @@ The procedure below is an example of using a ConnectX-5 adapter card (pf0) with #. For each VF PCIe, using the following command to bind the driver:: $ echo "0000:82:00.2" >> /sys/bus/pci/drivers/mlx5_core/bind + +Available descriptor threshold introduction +------------------------------------------- + +Available descriptor threshold is a per Rx queue attribute, it should be configured as +a percentage of the Rx queue size. +When Rx queue available descriptors for hardware are below the threshold, an event is sent to PMD. +
doc/guides/rel_notes/release_22_07.rst +1 -0
@@ -151,6 +151,7 @@ New Features * Added support for promiscuous mode on Windows. * Added support for MTU on Windows. * Added matching and RSS on IPsec ESP. + * Added Rx queue available descriptor threshold support. * **Updated VMware vmxnet3 networking driver.**
drivers/common/mlx5/mlx5_prm.h +1 -0
@@ -3294,6 +3294,7 @@ struct mlx5_aso_wqe {enum {MLX5_EVENT_TYPE_OBJECT_CHANGE =0x27 , +MLX5_EVENT_TYPE_SRQ_LIMIT_REACHED =0x14 , };enum {
drivers/net/mlx5/mlx5.c +2 -0
@@ -2071,6 +2071,8 @@ struct mlx5_dev_ctx_shared * .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get, .vlan_filter_set = mlx5_vlan_filter_set, .rx_queue_setup = mlx5_rx_queue_setup, + .rx_queue_avail_thresh_set = mlx5_rx_queue_lwm_set, + .rx_queue_avail_thresh_query = mlx5_rx_queue_lwm_query, .rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup, .tx_queue_setup = mlx5_tx_queue_setup, .tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
drivers/net/mlx5/mlx5_rx.c +151 -0
184 lines not on this page · raw message
drivers/net/mlx5/mlx5_rx.h +5 -0
@@ -177,6 +177,7 @@ struct mlx5_rxq_priv {uint32_t hairpin_status;/* Hairpin binding status. */ uint32_t lwm:16; uint32_t lwm_event_pending:1; + uint32_t lwm_devx_subscribed:1; };/* External RX queue descriptor. */
@@ -297,6 +298,10 @@ int mlx5_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t rx_queue_id, struct rte_eth_burst_mode *mode);int mlx5_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc);void mlx5_dev_interrupt_handler_lwm (void *args); +int mlx5_rx_queue_lwm_set (struct rte_eth_dev *dev,uint16_t rx_queue_id, +uint8_t lwm); +int mlx5_rx_queue_lwm_query (struct rte_eth_dev *dev,uint16_t *rx_queue_id, +uint8_t *lwm);/* Vectorized version of mlx5_rx.c */ int mlx5_rxq_check_vec_support (struct mlx5_rxq_data *rxq_data);
Signature · 1 line
1.8.3.1
PATCH v9 5/6 net/mlx5: add private API to config host port shaper
In reply to Spike DuHost port shaper can be configured with QSHR(QoS Shaper Host Register). Add check in build files to enable this function or not.
The host shaper configuration affects all the ethdev ports belonging to the same host port.
Host shaper can configure shaper rate and lwm-triggered for a host port. The shaper limits the rate of traffic from host port to wire port. If lwm-triggered is enabled, a 100Mbps shaper is enabled automatically when one of the host port's Rx queues receives available descriptor threshold event.
--- doc/guides/nics/mlx5.rst | 35 +++++++++++ doc/guides/rel_notes/release_22_07.rst | 1 + drivers/common/mlx5/linux/meson.build | 13 +++++ drivers/common/mlx5/mlx5_prm.h | 25 ++++++++ drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_rx.c | 104 +++++++++++++++++++++++++++++++++ drivers/net/mlx5/rte_pmd_mlx5.h | 30 ++++++++++ drivers/net/mlx5/version.map | 2 + 8 files changed, 212 insertions(+)
doc/guides/nics/mlx5.rst +35 -0
@@ -94,6 +94,7 @@ Features - Sub-Function representors. - Sub-Function. - Rx queue available descriptor threshold configuration. +- Host shaper support. Limitations
@@ -525,6 +526,12 @@ Limitations - Doesn't support shared Rx queue and Hairpin Rx queue. +- Host shaper: + + - Support BlueField series NIC from BlueField 2. + - When configure host shaper with MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED flag set, + only rate 0 and 100Mbps are supported. + Statistics ----------
@@ -1692,3 +1699,31 @@ Available descriptor threshold is a per Rx queue attribute, it should be configu a percentage of the Rx queue size. When Rx queue available descriptors for hardware are below the threshold, an event is sent to PMD. +Host shaper introduction +------------------------ + +Host shaper register is per host port register which sets a shaper +on the host port. +All VF/hostPF representors belonging to one host port share one host shaper. +For example, if representor 0 and representor 1 belong to same host port, +and a host shaper rate of 1Gbps is configured, the shaper throttles both +representors' traffic from host. +Host shaper has two modes for setting the shaper, immediate and deferred to +available descriptor threshold event trigger. In immediate mode, the rate limit is configured +immediately to host shaper. When deferring to available descriptor threshold trigger, the shaper +is not set until an available descriptor threshold event is received by any Rx queue in a VF +representor belonging to the host port. The only rate supported for deferred +mode is 100Mbps (there is no limit on the supported rates for immediate mode). +In deferred mode, the shaper is set on the host port by the firmware upon +receiving the available descriptor threshold event, which allows throttling host traffic on +available descriptor threshold events at minimum latency, preventing excess drops in the +Rx queue. + +Host shaper dependency for mstflint package +------------------------------------------- + +In order to configure host shaper register, ``librte_net_mlx5`` depends on ``libmtcr_ul`` +which can be installed from OFED mstflint package. +Meson detects ``libmtcr_ul`` existence at configure stage. +If the library is detected, the application must link with ``-lmtcr_ul``, +as done by the pkg-config file libdpdk.pc.
doc/guides/rel_notes/release_22_07.rst +1 -0
@@ -152,6 +152,7 @@ New Features * Added support for MTU on Windows. * Added matching and RSS on IPsec ESP. * Added Rx queue available descriptor threshold support. + * Added host shaper support. * **Updated VMware vmxnet3 networking driver.**
drivers/common/mlx5/linux/meson.build +13 -0
@@ -45,6 +45,13 @@ if static_ibverbs ext_deps += declare_dependency(link_args:ibv_ldflags.split()) endif +libmtcr_ul_found = false +lib = cc.find_library('mtcr_ul', required:false) +if lib.found() and run_command('meson', '--version').stdout().version_compare('>= 0.49.2') + libmtcr_ul_found = true + ext_deps += lib +endif + sources += files('mlx5_nl.c') sources += files('mlx5_common_auxiliary.c') sources += files('mlx5_common_os.c')
@@ -207,6 +214,12 @@ has_sym_args = [ [ 'HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR', 'infiniband/verbs.h', 'ibv_import_device' ], ] +if libmtcr_ul_found + has_sym_args += [ + [ 'HAVE_MLX5_MSTFLINT', 'mstflint/mtcr.h', + 'mopen'], + ] +endif config = configuration_data() foreach arg:has_sym_args config.set(arg[0], cc.has_header_symbol(arg[1], arg[2], dependencies: libs))
drivers/common/mlx5/mlx5_prm.h +25 -0
@@ -3772,6 +3772,7 @@ enum {MLX5_CRYPTO_COMMISSIONING_REGISTER_ID =0xC003 ,MLX5_IMPORT_KEK_HANDLE_REGISTER_ID =0xC004 ,MLX5_CREDENTIAL_HANDLE_REGISTER_ID =0xC005 , + MLX5_QSHR_REGISTER_ID = 0x4030, }; struct mlx5_ifc_register_mtutc_bits {
@@ -3786,6 +3787,30 @@ struct mlx5_ifc_register_mtutc_bits {u8 time_adjustment[0x20 ]; }; +struct mlx5_ifc_ets_global_config_register_bits { +u8 reserved_at_0[0x2 ]; +u8 rate_limit_update[0x1 ]; +u8 reserved_at_3[0x29 ]; +u8 max_bw_units[0x4 ]; +u8 reserved_at_48[0x8 ]; +u8 max_bw_value[0x8 ]; +}; + +#define ETS_GLOBAL_CONFIG_BW_UNIT_DISABLED 0x0 +#define ETS_GLOBAL_CONFIG_BW_UNIT_HUNDREDS_MBPS 0x3 +#define ETS_GLOBAL_CONFIG_BW_UNIT_GBPS 0x4 + +struct mlx5_ifc_register_qshr_bits { +u8 reserved_at_0[0x4 ]; +u8 connected_host[0x1 ]; +u8 vqos[0x1 ]; +u8 fast_response[0x1 ]; +u8 reserved_at_7[0x1 ]; +u8 local_port[0x8 ]; +u8 reserved_at_16[0x230 ]; +struct mlx5_ifc_ets_global_config_register_bits global_config; +}; +#define MLX5_MTUTC_TIMESTAMP_MODE_INTERNAL_TIMER 0#define MLX5_MTUTC_TIMESTAMP_MODE_REAL_TIME 1
drivers/net/mlx5/mlx5.h +2 -0
@@ -1271,6 +1271,8 @@ struct mlx5_dev_ctx_shared {void *devx_channel_lwm;struct rte_intr_handle *intr_handle_lwm;pthread_mutex_t lwm_config_lock; + uint32_t host_shaper_rate:8; + uint32_t lwm_triggered:1;/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
drivers/net/mlx5/mlx5_rx.c +104 -0
119 lines not on this page · raw message
drivers/net/mlx5/rte_pmd_mlx5.h +30 -0
@@ -109,6 +109,36 @@ int rte_pmd_mlx5_external_rx_queue_id_map(uint16_t port_id, uint16_t dpdk_idx,int rte_pmd_mlx5_external_rx_queue_id_unmap (uint16_t port_id,uint16_t dpdk_idx); +/** +* The rate of the host port shaper will be updated directly at the next +* available descriptor threshold event to the rate that comes with this flag set; +* set rate 0 to disable this rate update. +* Unset this flag to update the rate of the host port shaper directly in +* the API call; use rate 0 to disable the current shaper. +*/ +#define MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED 0 + +/** +* Configure a HW shaper to limit Tx rate for a host port. +* The configuration will affect all the ethdev ports belonging to +* the same rte_device. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] rate +* Unit is 100Mbps, setting the rate to 0 disables the shaper. +* @param[in] flags +* Host shaper flags. +* @return +* 0 : operation success. +* Otherwise: +* - ENOENT - no ibdev interface. +* - EBUSY - the register access unit is busy. +* - EIO - the register access command meets IO error. +*/ +__rte_experimental +int rte_pmd_mlx5_host_shaper_config(int port_id, uint8_t rate, uint32_t flags); + #ifdef __cplusplus }#endif
drivers/net/mlx5/version.map +2 -0
@@ -12,4 +12,6 @@ EXPERIMENTAL { # added in 22.03 rte_pmd_mlx5_external_rx_queue_id_map; rte_pmd_mlx5_external_rx_queue_id_unmap; + # added in 22.07 + rte_pmd_mlx5_host_shaper_config; };
Signature · 1 line
1.8.3.1
PATCH v9 6/6 app/testpmd: add Host Shaper command
In reply to Spike DuAdd command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id> host_shaper avail_thresh_triggered <0|1> rate
<rate_num>
- Example commands:
To enable avail_thresh_triggered on port 1 and disable current host shaper:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0
To disable avail_thresh_triggered and current host shaper on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0
The rate unit is 100Mbps.
To disable avail_thresh_triggered and configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50
Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
--- app/test-pmd/testpmd.c | 7 ++ doc/guides/nics/mlx5.rst | 46 +++++++++ drivers/net/mlx5/meson.build | 4 + drivers/net/mlx5/mlx5_testpmd.c | 205 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++++ 5 files changed, 288 insertions(+) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
app/test-pmd/testpmd.c +7 -0
@@ -69,6 +69,9 @@#ifdef RTE_NET_BOND #include <rte_eth_bond.h> #endif +#ifdef RTE_NET_MLX5 +#include "mlx5_testpmd.h" +#endif #include "testpmd.h"
@@ -3726,6 +3729,10 @@ struct pmd_test_command {break ;printf ("Received avail_thresh event, port: %u, rxq_id: %u\n" , port_id, rxq_id); + +#ifdef RTE_NET_MLX5 +mlx5_test_avail_thresh_event_handler (port_id, rxq_id); +#endif }break ; }
doc/guides/nics/mlx5.rst +46 -0
49 lines not on this page · raw message
drivers/net/mlx5/meson.build +4 -0
@@ -68,4 +68,8 @@ if get_option('buildtype').contains('debug') else cflags += [ '-UPEDANTIC' ] endif + +testpmd_sources += files('mlx5_testpmd.c') +testpmd_drivers_deps += 'net_mlx5' + subdir(exec_env)
drivers/net/mlx5/mlx5_testpmd.c new file +205 -0
205 lines not on this page · raw message
drivers/net/mlx5/mlx5_testpmd.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 6WIND S.A. +* Copyright 2021 Mellanox Technologies, Ltd +*/ + +#ifndef RTE_PMD_MLX5_TEST_H_ +#define RTE_PMD_MLX5_TEST_H_ + +#include <cmdline_parse.h> +#include <cmdline_parse_num.h> +#include <cmdline_parse_string.h> + +/** +* RTE_ETH_EVENT_RX_AVAIL_THRESH handler sample code. +* It's called in testpmd, the work flow here is delay a while until +* RX queueu is empty, then disable host shaper. +* +* @param[in] port_id +* Port identifier. +* @param[in] rxq_id +* Rx queue identifier. +*/ +void +mlx5_test_avail_thresh_event_handler (uint16_t port_id,uint16_t rxq_id); + +#endif
Signature · 1 line
1.8.3.1
v10 cover introduce per-queue available descriptor threshold and host shaper
In reply to Spike Duavailable descriptor threshold(ADT for short) is per RX queue attribute, when RX queue available descriptors for HW is below ADT, HW sends an event to application. Host shaper can configure shaper rate and avail_thresh-triggered for a host port.
The shaper limits the rate of traffic from host port to embedded ARM rx port on Nvidia BlueField 2 NIC.
If avail_thresh-triggered is enabled, a 100Mbps shaper is enabled automatically when one of the host port's Rx queues receives available descriptor threshold event.
These two features can combine to control traffic from host port to wire port for BlueField 2 NIC.
The traffic flows from host to embedded ARM, then to the physical port.
The work flow is on the ARM system, configure available descriptor threshold to RX queue and enable avail_thresh-triggered flag in host shaper, after receiving available descriptor threshold event, delay a while until RX queue is empty , then disable the shaper. We recycle this work flow to reduce RX queue drops on ARM system.
Add new libethdev API to set available descriptor threshold, add rte event RTE_ETH_EVENT_RX_AVAIL_THRESH to handle available descriptor threshold event. For host shaper, because it doesn't align to existing DPDK framework and is specific to Nvidia NIC, use PMD private API.
For integration with testpmd, put the private cmdline function and available descriptor threshold event handler in mlx5 PMD directory by adding a new file mlx5_testpmd.c. Follow David Marchand's driver specific commands framework to add mlx5 specific commands.
Spike Du (6):
net/mlx5: add LWM support for Rxq
common/mlx5: share interrupt management
net/mlx5: add LWM event handling support
net/mlx5: support Rx queue based available descriptor threshold net/mlx5: add private API to config host port shaper app/testpmd: add Host Shaper command
app/test-pmd/testpmd.c | 7 + doc/guides/nics/mlx5.rst | 93 +++++++++ doc/guides/rel_notes/release_22_07.rst | 2 + drivers/common/mlx5/linux/meson.build | 13 ++ drivers/common/mlx5/linux/mlx5_common_os.c | 131 ++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 11 + drivers/common/mlx5/mlx5_prm.h | 26 +++ drivers/common/mlx5/version.map | 2 + drivers/common/mlx5/windows/mlx5_common_os.h | 24 +++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 71 ------- drivers/net/mlx5/linux/mlx5_os.c | 132 +++--------- drivers/net/mlx5/linux/mlx5_socket.c | 53 +---- drivers/net/mlx5/meson.build | 3 + drivers/net/mlx5/mlx5.c | 68 +++++++ drivers/net/mlx5/mlx5.h | 12 +- drivers/net/mlx5/mlx5_devx.c | 60 +++++- drivers/net/mlx5/mlx5_devx.h | 1 + drivers/net/mlx5/mlx5_rx.c | 288 +++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 13 ++ drivers/net/mlx5/mlx5_testpmd.c | 205 +++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++ drivers/net/mlx5/mlx5_txpp.c | 28 +-- drivers/net/mlx5/rte_pmd_mlx5.h | 30 +++ drivers/net/mlx5/version.map | 2 + drivers/net/mlx5/windows/mlx5_ethdev_os.c | 22 -- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 48 +---- 26 files changed, 1063 insertions(+), 308 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
Signature · 1 line
1.8.3.1
PATCH v10 1/6 net/mlx5: add LWM support for Rxq
Add lwm(Limit WaterMark) field to Rxq object which indicates the percentage of RX queue size used by HW to raise LWM event to the user. Allow LWM setting in modify_rq command.
Allow the LWM configuration dynamically by adding RDY2RDY state change.
--- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_devx.c | 13 ++++++++++++- drivers/net/mlx5/mlx5_devx.h | 1 + drivers/net/mlx5/mlx5_rx.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-)
drivers/net/mlx5/mlx5.h +1 -0
@@ -1395,6 +1395,7 @@ enum mlx5_rxq_modify_type {MLX5_RXQ_MOD_RST2RDY ,/* modify state from reset to ready. */ MLX5_RXQ_MOD_RDY2ERR ,/* modify state from ready to error. */ MLX5_RXQ_MOD_RDY2RST ,/* modify state from ready to reset. */ + MLX5_RXQ_MOD_RDY2RDY, /* modify state from ready to ready. */ }; enum mlx5_txq_modify_type {
drivers/net/mlx5/mlx5_devx.c +12 -1
@@ -62,7 +62,7 @@* @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ -static int +int mlx5_devx_modify_rq (struct mlx5_rxq_priv *rxq,uint8_t type) {struct mlx5_devx_modify_rq_attr rq_attr;
@@ -76,6 +76,11 @@case MLX5_RXQ_MOD_RST2RDY : rq_attr.rq_state =MLX5_RQC_STATE_RST ; rq_attr.state =MLX5_RQC_STATE_RDY ; +if (rxq->lwm) { + rq_attr.modify_bitmask |= +MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM ; + rq_attr.lwm = rxq->lwm; + }break ;case MLX5_RXQ_MOD_RDY2ERR : rq_attr.rq_state =MLX5_RQC_STATE_RDY ;
@@ -85,6 +90,12 @@ rq_attr.rq_state =MLX5_RQC_STATE_RDY ; rq_attr.state =MLX5_RQC_STATE_RST ;break ; +case MLX5_RXQ_MOD_RDY2RDY : + rq_attr.rq_state =MLX5_RQC_STATE_RDY ; + rq_attr.state =MLX5_RQC_STATE_RDY ; + rq_attr.modify_bitmask |=MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_WQ_LWM ; + rq_attr.lwm = rxq->lwm; +break ;default :break ; }
drivers/net/mlx5/mlx5_devx.h +1 -0
@@ -11,6 +11,7 @@int mlx5_txq_devx_modify (struct mlx5_txq_obj *obj,enum mlx5_txq_modify_type type,uint8_t dev_port);void mlx5_txq_devx_obj_release (struct mlx5_txq_obj *txq_obj); +int mlx5_devx_modify_rq (struct mlx5_rxq_priv *rxq,uint8_t type);extern struct mlx5_obj_ops devx_obj_ops;
drivers/net/mlx5/mlx5_rx.h +1 -0
@@ -175,6 +175,7 @@ struct mlx5_rxq_priv {struct mlx5_devx_rq devx_rq;struct rte_eth_hairpin_conf hairpin_conf;/* Hairpin configuration. */ uint32_t hairpin_status;/* Hairpin binding status. */ + uint32_t lwm:16; };/* External RX queue descriptor. */
Signature · 1 line
1.8.3.1
PATCH v10 2/6 common/mlx5: share interrupt management
In reply to Spike DuThere are many duplicate code of creating and initializing rte_intr_handle. Add a new mlx5_os API to do this, replace all PMD related code with this API.
--- drivers/common/mlx5/linux/mlx5_common_os.c | 131 ++++++++++++++++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 11 +++ drivers/common/mlx5/version.map | 2 + drivers/common/mlx5/windows/mlx5_common_os.h | 24 +++++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 71 -------------- drivers/net/mlx5/linux/mlx5_os.c | 132 ++++++--------------------- drivers/net/mlx5/linux/mlx5_socket.c | 53 ++--------- drivers/net/mlx5/mlx5.h | 2 - drivers/net/mlx5/mlx5_txpp.c | 28 ++---- drivers/net/mlx5/windows/mlx5_ethdev_os.c | 22 ----- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 48 ++-------- 11 files changed, 217 insertions(+), 307 deletions(-)
drivers/common/mlx5/linux/mlx5_common_os.c +131 -0
@@ -11,6 +11,7 @@#endif #include <dirent.h> #include <net/if.h> +#include <fcntl.h> #include <rte_errno.h> #include <rte_string_fns.h>
@@ -964,3 +965,133 @@claim_zero (mlx5_glue->dereg_mr (pmd_mr->obj));memset (pmd_mr,0 ,sizeof (*pmd_mr)); } + +/** +* Rte_intr_handle create and init helper. +* +* @param[in] mode +* interrupt instance can be shared between primary and secondary +* processes or not. +* @param[in] set_fd_nonblock +* Whether to set fd to O_NONBLOCK. +* @param[in] fd +* Fd to set in created intr_handle. +* @param[in] cb +* Callback to register for intr_handle. +* @param[in] cb_arg +* Callback argument for cb. +* +* @return +* - Interrupt handle on success. +* - NULL on failure, with rte_errno set. +*/ +struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg) +{ +struct rte_intr_handle *tmp_intr_handle; +int ret, flags; + + tmp_intr_handle =rte_intr_instance_alloc (mode); +if (!tmp_intr_handle) { + rte_errno =ENOMEM ; + goto err; + } +if (set_fd_nonblock) { + flags =fcntl (fd,F_GETFL ); + ret =fcntl (fd,F_SETFL , flags |O_NONBLOCK ); +if (ret) { + rte_errno = errno; + goto err; + } + } + ret =rte_intr_fd_set (tmp_intr_handle, fd); +if (ret) + goto err; + ret =rte_intr_type_set (tmp_intr_handle,RTE_INTR_HANDLE_EXT ); +if (ret) + goto err; + ret =rte_intr_callback_register (tmp_intr_handle, cb, cb_arg); +if (ret) { + rte_errno = -ret; + goto err; + } +return tmp_intr_handle; +err: +if (tmp_intr_handle) +rte_intr_instance_free (tmp_intr_handle); +return NULL ; +} + +/* Safe unregistration for interrupt callback. */ +static void +mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, +rte_intr_callback_fn cb_fn,void *cb_arg) +{ +uint64_t twait =0 ; +uint64_t start =0 ; + +do { +int ret; + + ret =rte_intr_callback_unregister (handle, cb_fn, cb_arg); +if (ret >=0 ) +return ; +if (ret != -EAGAIN ) { +DRV_LOG (INFO ,"failed to unregister interrupt" +" handler (error: %d)" , ret); +MLX5_ASSERT (false); +return ; + } +if (twait) { +struct timespec onems; + +/* Wait one millisecond and try again. */ + onems.tv_sec =0 ; + onems.tv_nsec =NS_PER_S /MS_PER_S ; +nanosleep (&onems,0 ); +/* Check whether one second elapsed. */ +if ((rte_get_timer_cycles () - start) <= twait) +continue ; + }else { +/* +* We get the amount of timer ticks for one second. +* If this amount elapsed it means we spent one +* second in waiting. This branch is executed once +* on first iteration. +*/ + twait =rte_get_timer_hz (); +MLX5_ASSERT (twait); + } +/* +* Timeout elapsed, show message (once a second) and retry. +* We have no other acceptable option here, if we ignore +* the unregistering return code the handler will not +* be unregistered, fd will be closed and we may get the +* crush. Hanging and messaging in the loop seems not to be +* the worst choice. +*/ +DRV_LOG (INFO ,"Retrying to unregister interrupt handler" ); + start =rte_get_timer_cycles (); + }while (true); +} + +/** +* Rte_intr_handle destroy helper. +* +* @param[in] intr_handle +* Rte_intr_handle to destroy. +* @param[in] cb +* Callback which is registered to intr_handle. +* @param[in] cb_arg +* Callback argument for cb. +* +*/ +void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg) +{ +if (rte_intr_fd_get (intr_handle) >=0 ) +mlx5_intr_callback_unregister (intr_handle, cb, cb_arg); +rte_intr_instance_free (intr_handle); +}
drivers/common/mlx5/linux/mlx5_common_os.h +11 -0
@@ -15,6 +15,7 @@#include <rte_log.h> #include <rte_kvargs.h> #include <rte_devargs.h> +#include <rte_interrupts.h> #include "mlx5_autoconf.h" #include "mlx5_glue.h"
@@ -299,4 +300,14 @@int mlx5_get_device_guid (const struct rte_pci_addr *dev,uint8_t *guid,size_t len); +__rte_internal +struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg); + +__rte_internal +void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg); +#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/common/mlx5/version.map +2 -0
@@ -153,5 +153,7 @@ INTERNAL { mlx5_mr_mempool2mr_bh; mlx5_mr_mempool_populate_cache; + mlx5_os_interrupt_handler_create; # WINDOWS_NO_EXPORT + mlx5_os_interrupt_handler_destroy; # WINDOWS_NO_EXPORT local: *; };
drivers/common/mlx5/windows/mlx5_common_os.h +24 -0
@@ -9,6 +9,7 @@#include <sys/types.h> #include <rte_errno.h> +#include <rte_interrupts.h> #include "mlx5_autoconf.h" #include "mlx5_glue.h"
@@ -253,4 +254,27 @@__rte_internal int mlx5_os_umem_dereg(void *pumem); +static inline struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg) +{ + (void )mode; + (void )set_fd_nonblock; + (void )fd; + (void )cb; + (void )cb_arg; + rte_errno =ENOTSUP ; +return NULL ; +} + +static inline void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg) +{ + (void )intr_handle; + (void )cb; + (void )cb_arg; +} + +#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */
drivers/net/mlx5/linux/mlx5_ethdev_os.c +0 -71
77 lines not on this page · raw message
drivers/net/mlx5/linux/mlx5_os.c +29 -103
169 lines not on this page · raw message
drivers/net/mlx5/linux/mlx5_socket.c +6 -47
71 lines not on this page · raw message
drivers/net/mlx5/mlx5.h +0 -2
@@ -1682,8 +1682,6 @@ int mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info);void mlx5_translate_port_name (const char *port_name_in,struct mlx5_switch_info *port_info_out); -void mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, -rte_intr_callback_fn cb_fn,void *cb_arg);int mlx5_sysfs_bond_info (unsigned int pf_ifindex,unsigned int *ifindex,char *ifname); int mlx5_get_module_info(struct rte_eth_dev *dev,
drivers/net/mlx5/mlx5_txpp.c +7 -21
@@ -741,11 +741,8 @@static void mlx5_txpp_stop_service (struct mlx5_dev_ctx_shared *sh) { -if (!rte_intr_fd_get (sh->txpp.intr_handle)) -return ; -mlx5_intr_callback_unregister (sh->txpp.intr_handle, - mlx5_txpp_interrupt_handler, sh); -rte_intr_instance_free (sh->txpp.intr_handle); +mlx5_os_interrupt_handler_destroy (sh->txpp.intr_handle, + mlx5_txpp_interrupt_handler, sh); }/* Attach interrupt handler and fires first request to Rearm Queue. */
@@ -769,23 +766,12 @@ rte_errno = errno;return -rte_errno; } - sh->txpp.intr_handle = -rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_SHARED ); -if (sh->txpp.intr_handle ==NULL ) { -DRV_LOG (ERR ,"Fail to allocate intr_handle" ); -return -ENOMEM ; - } fd =mlx5_os_get_devx_channel_fd (sh->txpp.echan); -if (rte_intr_fd_set (sh->txpp.intr_handle, fd)) -return -rte_errno; - -if (rte_intr_type_set (sh->txpp.intr_handle,RTE_INTR_HANDLE_EXT )) -return -rte_errno; - -if (rte_intr_callback_register (sh->txpp.intr_handle, - mlx5_txpp_interrupt_handler, sh)) { -rte_intr_fd_set (sh->txpp.intr_handle,0 ); -DRV_LOG (ERR ,"Failed to register CQE interrupt %d." , rte_errno); + sh->txpp.intr_handle =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , false, + fd, mlx5_txpp_interrupt_handler, sh); +if (!sh->txpp.intr_handle) { +DRV_LOG (ERR ,"Fail to allocate intr_handle" );return -rte_errno; }/* Subscribe CQ event to the event channel controlled by the driver. */
drivers/net/mlx5/windows/mlx5_ethdev_os.c +0 -22
@@ -140,28 +140,6 @@return 0 ; } -/* -* Unregister callback handler safely. The handler may be active -* while we are trying to unregister it, in this case code -EAGAIN -* is returned by rte_intr_callback_unregister(). This routine checks -* the return code and tries to unregister handler again. -* -* @param handle -* interrupt handle -* @param cb_fn -* pointer to callback routine -* @cb_arg -* opaque callback parameter -*/ -void -mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, -rte_intr_callback_fn cb_fn,void *cb_arg) -{ -RTE_SET_USED (handle); -RTE_SET_USED (cb_fn); -RTE_SET_USED (cb_arg); -} -/** * DPDK callback to get flow control status. *
drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +7 -41
64 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v10 3/6 net/mlx5: add LWM event handling support
In reply to Spike DuWhen LWM meets RQ WQE, the kernel driver raises an event to SW. Use devx event_channel to catch this and to notify the user. Allocate this channel per shared device.
The channel has a cookie that informs the specific event port and queue.
--- drivers/net/mlx5/mlx5.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5.h | 7 +++++ drivers/net/mlx5/mlx5_devx.c | 47 +++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.c | 33 ++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 7 +++++ 5 files changed, 160 insertions(+)
drivers/net/mlx5/mlx5.c +66 -0
@@ -9,6 +9,7 @@#include <stdint.h> #include <stdlib.h> #include <errno.h> +#include <fcntl.h> #include <rte_malloc.h> #include <ethdev_driver.h>
@@ -22,6 +23,7 @@#include <rte_eal_paging.h> #include <rte_alarm.h> #include <rte_cycles.h> +#include <rte_interrupts.h> #include <mlx5_glue.h> #include <mlx5_devx_cmds.h>
@@ -1525,6 +1527,69 @@ struct mlx5_dev_ctx_shared * }/** +* Create LWM event_channel and interrupt handle for shared device +* context. All rxqs sharing the device context share the event_channel. +* A callback is registered in interrupt thread to receive the LWM event. +* +* @param[in] priv +* Pointer to mlx5_priv instance. +* +* @return +* 0 on success, negative with rte_errno set. +*/ +int +mlx5_lwm_setup (struct mlx5_priv *priv) +{ +int fd_lwm; + +pthread_mutex_init (&priv->sh->lwm_config_lock,NULL ); + priv->sh->devx_channel_lwm =mlx5_os_devx_create_event_channel + (priv->sh->cdev->ctx, +MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA ); +if (!priv->sh->devx_channel_lwm) + goto err; + fd_lwm =mlx5_os_get_devx_channel_fd (priv->sh->devx_channel_lwm); + priv->sh->intr_handle_lwm =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , true, + fd_lwm, mlx5_dev_interrupt_handler_lwm, priv); +if (!priv->sh->intr_handle_lwm) + goto err; +return 0 ; +err: +if (priv->sh->devx_channel_lwm) { +mlx5_os_devx_destroy_event_channel + (priv->sh->devx_channel_lwm); + priv->sh->devx_channel_lwm =NULL ; + } +pthread_mutex_destroy (&priv->sh->lwm_config_lock); +return -rte_errno; +} + +/** +* Destroy LWM event_channel and interrupt handle for shared device +* context before free this context. The interrupt handler is also +* unregistered. +* +* @param[in] sh +* Pointer to shared device context. +*/ +void +mlx5_lwm_unset (struct mlx5_dev_ctx_shared *sh) +{ +if (sh->intr_handle_lwm) { +mlx5_os_interrupt_handler_destroy (sh->intr_handle_lwm, + mlx5_dev_interrupt_handler_lwm, (void *)-1 ); + sh->intr_handle_lwm =NULL ; + } +if (sh->devx_channel_lwm) { +mlx5_os_devx_destroy_event_channel + (sh->devx_channel_lwm); + sh->devx_channel_lwm =NULL ; + } +pthread_mutex_destroy (&sh->lwm_config_lock); +} + +/** * Free shared IB device context. Decrement counter and if zero free * all allocated resources and close handles. *
@@ -1601,6 +1666,7 @@ struct mlx5_dev_ctx_shared *claim_zero (mlx5_devx_cmd_destroy (sh->td));MLX5_ASSERT (sh->geneve_tlv_option_resource ==NULL );pthread_mutex_destroy (&sh->txpp.mutex); +mlx5_lwm_unset (sh);mlx5_free (sh);return ; exit:
drivers/net/mlx5/mlx5.h +7 -0
@@ -1268,6 +1268,9 @@ struct mlx5_dev_ctx_shared {struct mlx5_lb_ctx self_lb;/* QP to enable self loopback for Devx. */ unsigned int flow_max_priority;enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM ]; +void *devx_channel_lwm; +struct rte_intr_handle *intr_handle_lwm; +pthread_mutex_t lwm_config_lock;/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
@@ -1405,6 +1408,7 @@ enum mlx5_txq_modify_type { };struct mlx5_rxq_priv ; +struct mlx5_priv ;/* HW objects operations structure. */ struct mlx5_obj_ops {
@@ -1413,6 +1417,7 @@ struct mlx5_obj_ops {int (*rxq_event_get)(struct mlx5_rxq_obj *rxq_obj);int (*rxq_obj_modify)(struct mlx5_rxq_priv *rxq,uint8_t type);void (*rxq_obj_release)(struct mlx5_rxq_priv *rxq); +int (*rxq_event_get_lwm)(struct mlx5_priv *priv,int *rxq_idx,int *port_id);int (*ind_table_new)(struct rte_eth_dev *dev,const unsigned int log_n,struct mlx5_ind_table_obj *ind_tbl); int (*ind_table_modify)(struct rte_eth_dev *dev,
@@ -1603,6 +1608,8 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,bool mlx5_is_hpf (struct rte_eth_dev *dev);bool mlx5_is_sf_repr (struct rte_eth_dev *dev);void mlx5_age_event_prepare (struct mlx5_dev_ctx_shared *sh); +int mlx5_lwm_setup (struct mlx5_priv *priv); +void mlx5_lwm_unset (struct mlx5_dev_ctx_shared *sh);/* Macro to iterate over all valid ports for mlx5 driver. */ #define MLX5_ETH_FOREACH_DEV (port_id, dev) \
drivers/net/mlx5/mlx5_devx.c +47 -0
59 lines not on this page · raw message
drivers/net/mlx5/mlx5_rx.c +33 -0
@@ -1187,3 +1187,36 @@ int mlx5_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc) {return -ENOTSUP ; } + +/** +* Rte interrupt handler for LWM event. +* It first checks if the event arrives, if so process the callback for +* RTE_ETH_EVENT_RX_LWM. +* +* @param args +* Generic pointer to mlx5_priv. +*/ +void +mlx5_dev_interrupt_handler_lwm (void *args) +{ +struct mlx5_priv *priv = args; +struct mlx5_rxq_priv *rxq; +struct rte_eth_dev *dev; +int ret, rxq_idx =0 , port_id =0 ; + + ret = priv->obj_ops.rxq_event_get_lwm (priv, &rxq_idx, &port_id); +if (unlikely (ret <0 )) { +DRV_LOG (WARNING ,"Cannot get LWM event context." ); +return ; + } +DRV_LOG (INFO ,"%s get LWM event, port_id:%d rxq_id:%d." , __func__, + port_id, rxq_idx); + dev = &rte_eth_devices[port_id]; + rxq =mlx5_rxq_get (dev, rxq_idx); +if (rxq) { +pthread_mutex_lock (&priv->sh->lwm_config_lock); + rxq->lwm_event_pending =1 ; +pthread_mutex_unlock (&priv->sh->lwm_config_lock); + } +rte_eth_dev_callback_process (dev,RTE_ETH_EVENT_RX_AVAIL_THRESH ,NULL ); +}
drivers/net/mlx5/mlx5_rx.h +7 -0
@@ -176,6 +176,7 @@ struct mlx5_rxq_priv {struct rte_eth_hairpin_conf hairpin_conf;/* Hairpin configuration. */ uint32_t hairpin_status;/* Hairpin binding status. */ uint32_t lwm:16; + uint32_t lwm_event_pending:1; };/* External RX queue descriptor. */
@@ -295,6 +296,7 @@ void mlx5_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,int mlx5_rx_burst_mode_get (struct rte_eth_dev *dev,uint16_t rx_queue_id,struct rte_eth_burst_mode *mode);int mlx5_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc); +void mlx5_dev_interrupt_handler_lwm (void *args);/* Vectorized version of mlx5_rx.c */ int mlx5_rxq_check_vec_support (struct mlx5_rxq_data *rxq_data);
@@ -675,4 +677,9 @@ uint16_t mlx5_rx_burst_mprq_vec(void *dpdk_rxq, struct rte_mbuf **pkts, return !!__atomic_load_n(&rxq->refcnt, __ATOMIC_RELAXED); } +#define LWM_COOKIE_RXQID_OFFSET 0 +#define LWM_COOKIE_RXQID_MASK 0xffff +#define LWM_COOKIE_PORTID_OFFSET 16 +#define LWM_COOKIE_PORTID_MASK 0xffff +#endif /* RTE_PMD_MLX5_RX_H_ */
Signature · 1 line
1.8.3.1
PATCH v10 4/6 net/mlx5: support Rx queue based available descriptor threshold
In reply to Spike DuAdd mlx5 specific available descriptor threshold configuration and query handler.
In mlx5 PMD, available descriptor threshold is also called LWM(limit watermark).
While the Rx queue fullness reaches the LWM limit, the driver catches an HW event and invokes the user callback.
The query handler finds the next RX queue with pending LWM event if any, starting from the given RX queue index.
--- doc/guides/nics/mlx5.rst | 12 +++ doc/guides/rel_notes/release_22_07.rst | 1 + drivers/common/mlx5/mlx5_prm.h | 1 + drivers/net/mlx5/mlx5.c | 2 + drivers/net/mlx5/mlx5_rx.c | 151 +++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 5 ++ 6 files changed, 172 insertions(+)
doc/guides/nics/mlx5.rst +12 -0
@@ -93,6 +93,7 @@ Features - Connection tracking. - Sub-Function representors. - Sub-Function. +- Rx queue available descriptor threshold configuration. Limitations
@@ -520,6 +521,9 @@ Limitations - The NIC egress flow rules on representor port are not supported. +- Available descriptor threshold: + + - Doesn't support shared Rx queue and Hairpin Rx queue. Statistics ----------
@@ -1680,3 +1684,11 @@ The procedure below is an example of using a ConnectX-5 adapter card (pf0) with #. For each VF PCIe, using the following command to bind the driver:: $ echo "0000:82:00.2" >> /sys/bus/pci/drivers/mlx5_core/bind + +Available descriptor threshold introduction +------------------------------------------- + +Available descriptor threshold is a per Rx queue attribute, it should be configured as +a percentage of the Rx queue size. +When Rx queue available descriptors for hardware are below the threshold, an event is sent to PMD. +
doc/guides/rel_notes/release_22_07.rst +1 -0
@@ -151,6 +151,7 @@ New Features * Added support for promiscuous mode on Windows. * Added support for MTU on Windows. * Added matching and RSS on IPsec ESP. + * Added Rx queue available descriptor threshold support. * **Updated VMware vmxnet3 networking driver.**
drivers/common/mlx5/mlx5_prm.h +1 -0
@@ -3294,6 +3294,7 @@ struct mlx5_aso_wqe {enum {MLX5_EVENT_TYPE_OBJECT_CHANGE =0x27 , +MLX5_EVENT_TYPE_SRQ_LIMIT_REACHED =0x14 , };enum {
drivers/net/mlx5/mlx5.c +2 -0
@@ -2071,6 +2071,8 @@ struct mlx5_dev_ctx_shared * .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get, .vlan_filter_set = mlx5_vlan_filter_set, .rx_queue_setup = mlx5_rx_queue_setup, + .rx_queue_avail_thresh_set = mlx5_rx_queue_lwm_set, + .rx_queue_avail_thresh_query = mlx5_rx_queue_lwm_query, .rx_hairpin_queue_setup = mlx5_rx_hairpin_queue_setup, .tx_queue_setup = mlx5_tx_queue_setup, .tx_hairpin_queue_setup = mlx5_tx_hairpin_queue_setup,
drivers/net/mlx5/mlx5_rx.c +151 -0
184 lines not on this page · raw message
drivers/net/mlx5/mlx5_rx.h +5 -0
@@ -177,6 +177,7 @@ struct mlx5_rxq_priv {uint32_t hairpin_status;/* Hairpin binding status. */ uint32_t lwm:16; uint32_t lwm_event_pending:1; + uint32_t lwm_devx_subscribed:1; };/* External RX queue descriptor. */
@@ -297,6 +298,10 @@ int mlx5_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t rx_queue_id, struct rte_eth_burst_mode *mode);int mlx5_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc);void mlx5_dev_interrupt_handler_lwm (void *args); +int mlx5_rx_queue_lwm_set (struct rte_eth_dev *dev,uint16_t rx_queue_id, +uint8_t lwm); +int mlx5_rx_queue_lwm_query (struct rte_eth_dev *dev,uint16_t *rx_queue_id, +uint8_t *lwm);/* Vectorized version of mlx5_rx.c */ int mlx5_rxq_check_vec_support (struct mlx5_rxq_data *rxq_data);
Signature · 1 line
1.8.3.1
PATCH v10 5/6 net/mlx5: add private API to config host port shaper
In reply to Spike DuHost port shaper can be configured with QSHR(QoS Shaper Host Register). Add check in build files to enable this function or not.
The host shaper configuration affects all the ethdev ports belonging to the same host port.
Host shaper can configure shaper rate and lwm-triggered for a host port. The shaper limits the rate of traffic from host port to wire port. If lwm-triggered is enabled, a 100Mbps shaper is enabled automatically when one of the host port's Rx queues receives available descriptor threshold event.
--- doc/guides/nics/mlx5.rst | 35 +++++++++++ doc/guides/rel_notes/release_22_07.rst | 1 + drivers/common/mlx5/linux/meson.build | 13 +++++ drivers/common/mlx5/mlx5_prm.h | 25 ++++++++ drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_rx.c | 104 +++++++++++++++++++++++++++++++++ drivers/net/mlx5/rte_pmd_mlx5.h | 30 ++++++++++ drivers/net/mlx5/version.map | 2 + 8 files changed, 212 insertions(+)
doc/guides/nics/mlx5.rst +35 -0
@@ -94,6 +94,7 @@ Features - Sub-Function representors. - Sub-Function. - Rx queue available descriptor threshold configuration. +- Host shaper support. Limitations
@@ -525,6 +526,12 @@ Limitations - Doesn't support shared Rx queue and Hairpin Rx queue. +- Host shaper: + + - Support BlueField series NIC from BlueField 2. + - When configure host shaper with MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED flag set, + only rate 0 and 100Mbps are supported. + Statistics ----------
@@ -1692,3 +1699,31 @@ Available descriptor threshold is a per Rx queue attribute, it should be configu a percentage of the Rx queue size. When Rx queue available descriptors for hardware are below the threshold, an event is sent to PMD. +Host shaper introduction +------------------------ + +Host shaper register is per host port register which sets a shaper +on the host port. +All VF/hostPF representors belonging to one host port share one host shaper. +For example, if representor 0 and representor 1 belong to same host port, +and a host shaper rate of 1Gbps is configured, the shaper throttles both +representors' traffic from host. +Host shaper has two modes for setting the shaper, immediate and deferred to +available descriptor threshold event trigger. In immediate mode, the rate limit is configured +immediately to host shaper. When deferring to available descriptor threshold trigger, the shaper +is not set until an available descriptor threshold event is received by any Rx queue in a VF +representor belonging to the host port. The only rate supported for deferred +mode is 100Mbps (there is no limit on the supported rates for immediate mode). +In deferred mode, the shaper is set on the host port by the firmware upon +receiving the available descriptor threshold event, which allows throttling host traffic on +available descriptor threshold events at minimum latency, preventing excess drops in the +Rx queue. + +Host shaper dependency for mstflint package +------------------------------------------- + +In order to configure host shaper register, ``librte_net_mlx5`` depends on ``libmtcr_ul`` +which can be installed from OFED mstflint package. +Meson detects ``libmtcr_ul`` existence at configure stage. +If the library is detected, the application must link with ``-lmtcr_ul``, +as done by the pkg-config file libdpdk.pc.
doc/guides/rel_notes/release_22_07.rst +1 -0
@@ -152,6 +152,7 @@ New Features * Added support for MTU on Windows. * Added matching and RSS on IPsec ESP. * Added Rx queue available descriptor threshold support. + * Added host shaper support. * **Updated VMware vmxnet3 networking driver.**
drivers/common/mlx5/linux/meson.build +13 -0
@@ -45,6 +45,13 @@ if static_ibverbs ext_deps += declare_dependency(link_args:ibv_ldflags.split()) endif +libmtcr_ul_found = false +lib = cc.find_library('mtcr_ul', required:false) +if lib.found() and run_command('meson', '--version').stdout().version_compare('>= 0.49.2') + libmtcr_ul_found = true + ext_deps += lib +endif + sources += files('mlx5_nl.c') sources += files('mlx5_common_auxiliary.c') sources += files('mlx5_common_os.c')
@@ -207,6 +214,12 @@ has_sym_args = [ [ 'HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR', 'infiniband/verbs.h', 'ibv_import_device' ], ] +if libmtcr_ul_found + has_sym_args += [ + [ 'HAVE_MLX5_MSTFLINT', 'mstflint/mtcr.h', + 'mopen'], + ] +endif config = configuration_data() foreach arg:has_sym_args config.set(arg[0], cc.has_header_symbol(arg[1], arg[2], dependencies: libs))
drivers/common/mlx5/mlx5_prm.h +25 -0
@@ -3772,6 +3772,7 @@ enum {MLX5_CRYPTO_COMMISSIONING_REGISTER_ID =0xC003 ,MLX5_IMPORT_KEK_HANDLE_REGISTER_ID =0xC004 ,MLX5_CREDENTIAL_HANDLE_REGISTER_ID =0xC005 , + MLX5_QSHR_REGISTER_ID = 0x4030, }; struct mlx5_ifc_register_mtutc_bits {
@@ -3786,6 +3787,30 @@ struct mlx5_ifc_register_mtutc_bits {u8 time_adjustment[0x20 ]; }; +struct mlx5_ifc_ets_global_config_register_bits { +u8 reserved_at_0[0x2 ]; +u8 rate_limit_update[0x1 ]; +u8 reserved_at_3[0x29 ]; +u8 max_bw_units[0x4 ]; +u8 reserved_at_48[0x8 ]; +u8 max_bw_value[0x8 ]; +}; + +#define ETS_GLOBAL_CONFIG_BW_UNIT_DISABLED 0x0 +#define ETS_GLOBAL_CONFIG_BW_UNIT_HUNDREDS_MBPS 0x3 +#define ETS_GLOBAL_CONFIG_BW_UNIT_GBPS 0x4 + +struct mlx5_ifc_register_qshr_bits { +u8 reserved_at_0[0x4 ]; +u8 connected_host[0x1 ]; +u8 vqos[0x1 ]; +u8 fast_response[0x1 ]; +u8 reserved_at_7[0x1 ]; +u8 local_port[0x8 ]; +u8 reserved_at_16[0x230 ]; +struct mlx5_ifc_ets_global_config_register_bits global_config; +}; +#define MLX5_MTUTC_TIMESTAMP_MODE_INTERNAL_TIMER 0#define MLX5_MTUTC_TIMESTAMP_MODE_REAL_TIME 1
drivers/net/mlx5/mlx5.h +2 -0
@@ -1271,6 +1271,8 @@ struct mlx5_dev_ctx_shared {void *devx_channel_lwm;struct rte_intr_handle *intr_handle_lwm;pthread_mutex_t lwm_config_lock; + uint32_t host_shaper_rate:8; + uint32_t lwm_triggered:1;/* Availability of mreg_c's. */ struct mlx5_dev_shared_port port[];/* per device port data array. */ };
drivers/net/mlx5/mlx5_rx.c +104 -0
119 lines not on this page · raw message
drivers/net/mlx5/rte_pmd_mlx5.h +30 -0
@@ -109,6 +109,36 @@ int rte_pmd_mlx5_external_rx_queue_id_map(uint16_t port_id, uint16_t dpdk_idx,int rte_pmd_mlx5_external_rx_queue_id_unmap (uint16_t port_id,uint16_t dpdk_idx); +/** +* The rate of the host port shaper will be updated directly at the next +* available descriptor threshold event to the rate that comes with this flag set; +* set rate 0 to disable this rate update. +* Unset this flag to update the rate of the host port shaper directly in +* the API call; use rate 0 to disable the current shaper. +*/ +#define MLX5_HOST_SHAPER_FLAG_AVAIL_THRESH_TRIGGERED 0 + +/** +* Configure a HW shaper to limit Tx rate for a host port. +* The configuration will affect all the ethdev ports belonging to +* the same rte_device. +* +* @param[in] port_id +* The port identifier of the Ethernet device. +* @param[in] rate +* Unit is 100Mbps, setting the rate to 0 disables the shaper. +* @param[in] flags +* Host shaper flags. +* @return +* 0 : operation success. +* Otherwise: +* - ENOENT - no ibdev interface. +* - EBUSY - the register access unit is busy. +* - EIO - the register access command meets IO error. +*/ +__rte_experimental +int rte_pmd_mlx5_host_shaper_config(int port_id, uint8_t rate, uint32_t flags); + #ifdef __cplusplus }#endif
drivers/net/mlx5/version.map +2 -0
@@ -12,4 +12,6 @@ EXPERIMENTAL { # added in 22.03 rte_pmd_mlx5_external_rx_queue_id_map; rte_pmd_mlx5_external_rx_queue_id_unmap; + # added in 22.07 + rte_pmd_mlx5_host_shaper_config; };
Signature · 1 line
1.8.3.1
PATCH v10 6/6 app/testpmd: add Host Shaper command
In reply to Spike DuAdd command line options to support host shaper configure.
- Command syntax:
mlx5 set port <port_id> host_shaper avail_thresh_triggered <0|1> rate
<rate_num>
- Example commands:
To enable avail_thresh_triggered on port 1 and disable current host shaper:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0
To disable avail_thresh_triggered and current host shaper on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0
The rate unit is 100Mbps.
To disable avail_thresh_triggered and configure a shaper of 5Gbps on port 1:
testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50
Add sample code to handle rxq available descriptor threshold event, it delays a while so that rxq empties, then disables host shaper and rearms available descriptor threshold event.
--- app/test-pmd/testpmd.c | 7 ++ doc/guides/nics/mlx5.rst | 46 +++++++++ drivers/net/mlx5/meson.build | 3 + drivers/net/mlx5/mlx5_testpmd.c | 205 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++++ 5 files changed, 287 insertions(+) create mode 100644 drivers/net/mlx5/mlx5_testpmd.c create mode 100644 drivers/net/mlx5/mlx5_testpmd.h
app/test-pmd/testpmd.c +7 -0
@@ -69,6 +69,9 @@#ifdef RTE_NET_BOND #include <rte_eth_bond.h> #endif +#ifdef RTE_NET_MLX5 +#include "mlx5_testpmd.h" +#endif #include "testpmd.h"
@@ -3726,6 +3729,10 @@ struct pmd_test_command {break ;printf ("Received avail_thresh event, port: %u, rxq_id: %u\n" , port_id, rxq_id); + +#ifdef RTE_NET_MLX5 +mlx5_test_avail_thresh_event_handler (port_id, rxq_id); +#endif }break ; }
doc/guides/nics/mlx5.rst +46 -0
49 lines not on this page · raw message
drivers/net/mlx5/meson.build +3 -0
@@ -68,4 +68,7 @@ if get_option('buildtype').contains('debug') else cflags += [ '-UPEDANTIC' ] endif + +testpmd_sources += files('mlx5_testpmd.c') + subdir(exec_env)
drivers/net/mlx5/mlx5_testpmd.c new file +205 -0
205 lines not on this page · raw message
drivers/net/mlx5/mlx5_testpmd.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright 2021 6WIND S.A. +* Copyright 2021 Mellanox Technologies, Ltd +*/ + +#ifndef RTE_PMD_MLX5_TEST_H_ +#define RTE_PMD_MLX5_TEST_H_ + +#include <cmdline_parse.h> +#include <cmdline_parse_num.h> +#include <cmdline_parse_string.h> + +/** +* RTE_ETH_EVENT_RX_AVAIL_THRESH handler sample code. +* It's called in testpmd, the work flow here is delay a while until +* RX queueu is empty, then disable host shaper. +* +* @param[in] port_id +* Port identifier. +* @param[in] rxq_id +* Rx queue identifier. +*/ +void +mlx5_test_avail_thresh_event_handler (uint16_t port_id,uint16_t rxq_id); + +#endif
Signature · 1 line
1.8.3.1
RE: [PATCH v10 0/6] introduce per-queue available descriptor threshold and host shaper
In reply to Spike DuHi,
Quoted 78 lines
-----Original Message-----
From: Spike Du <[email protected]>
Sent: Thursday, June 16, 2022 11:42 AM
To: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Ori Kam <[email protected]>; NBU-Contact- Thomas Monjalon (EXTERNAL) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH v10 0/6] introduce per-queue available descriptor threshold and host shaperavailable descriptor threshold(ADT for short) is per RX queue attribute, when RX queue available descriptors for HW is below ADT, HW sends an event to application.
Host shaper can configure shaper rate and avail_thresh-triggered for a host port.
The shaper limits the rate of traffic from host port to embedded ARM rx port on Nvidia BlueField 2 NIC.
If avail_thresh-triggered is enabled, a 100Mbps shaper is enabled automatically when one of the host port's Rx queues receives available descriptor threshold event.These two features can combine to control traffic from host port to wire port for BlueField 2 NIC.
The traffic flows from host to embedded ARM, then to the physical port. The work flow is on the ARM system, configure available descriptor threshold to RX queue and enable avail_thresh-triggered flag in host shaper, after receiving available descriptor threshold event, delay a while until RX queue is empty , then disable the shaper. We recycle this work flow to reduce RX queue drops on ARM system.Add new libethdev API to set available descriptor threshold, add rte event
RTE_ETH_EVENT_RX_AVAIL_THRESHto handle available descriptor threshold event. For host shaper, because it doesn't align to existing DPDK framework and is specific to Nvidia NIC, use PMD private API.For integration with testpmd, put the private cmdline function and available descriptor threshold event handler in mlx5 PMD directory by adding a new file
mlx5_testpmd.c. Follow David Marchand's driver specific commands framework to add mlx5 specific commands.Spike Du (6):
net/mlx5: add LWM support for Rxq
common/mlx5: share interrupt management
net/mlx5: add LWM event handling support
net/mlx5: support Rx queue based available descriptor threshold net/mlx5: add private API to config host port shaper app/testpmd: add Host Shaper commandapp/test-pmd/testpmd.c | 7 + doc/guides/nics/mlx5.rst | 93 +++++++++ doc/guides/rel_notes/release_22_07.rst | 2 + drivers/common/mlx5/linux/meson.build | 13 ++ drivers/common/mlx5/linux/mlx5_common_os.c | 131 ++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 11 + drivers/common/mlx5/mlx5_prm.h | 26 +++ drivers/common/mlx5/version.map | 2 + drivers/common/mlx5/windows/mlx5_common_os.h | 24 +++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 71 ------- drivers/net/mlx5/linux/mlx5_os.c | 132 +++--------- drivers/net/mlx5/linux/mlx5_socket.c | 53 +---- drivers/net/mlx5/meson.build | 3 + drivers/net/mlx5/mlx5.c | 68 +++++++ drivers/net/mlx5/mlx5.h | 12 +- drivers/net/mlx5/mlx5_devx.c | 60 +++++- drivers/net/mlx5/mlx5_devx.h | 1 + drivers/net/mlx5/mlx5_rx.c | 288 +++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rx.h | 13 ++ drivers/net/mlx5/mlx5_testpmd.c | 205 +++++++++++++++++++ drivers/net/mlx5/mlx5_testpmd.h | 26 +++ drivers/net/mlx5/mlx5_txpp.c | 28 +-- drivers/net/mlx5/rte_pmd_mlx5.h | 30 +++ drivers/net/mlx5/version.map | 2 + drivers/net/mlx5/windows/mlx5_ethdev_os.c | 22 -- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 48 +---- 26 files changed, 1063 insertions(+), 308 deletions(-) create mode 100644
Quoted 5 lines
drivers/net/mlx5/mlx5_testpmd.ccreate mode 100644drivers/net/mlx5/mlx5_testpmd.h--
1.8.3.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
Re: [PATCH v10 2/6] common/mlx5: share interrupt management
In reply to Spike DuQuoted 218 lines · Spike Du
There are many duplicate code of creating and initializing
rte_intr_handle. Add a newmlx5_osAPI to do this, replace all PMD related code with this API.Signed-off-by Spike Du <[email protected]>Acked-by Matan Azard <[email protected]>--- drivers/common/mlx5/linux/mlx5_common_os.c | 131 ++++++++++++++++++++++++++ drivers/common/mlx5/linux/mlx5_common_os.h | 11 +++ drivers/common/mlx5/version.map | 2 + drivers/common/mlx5/windows/mlx5_common_os.h | 24 +++++ drivers/net/mlx5/linux/mlx5_ethdev_os.c | 71 -------------- drivers/net/mlx5/linux/mlx5_os.c | 132 ++++++--------------------- drivers/net/mlx5/linux/mlx5_socket.c | 53 ++--------- drivers/net/mlx5/mlx5.h | 2 - drivers/net/mlx5/mlx5_txpp.c | 28 ++---- drivers/net/mlx5/windows/mlx5_ethdev_os.c | 22 ----- drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 48 ++-------- 11 files changed, 217 insertions(+), 307 deletions(-)drivers/common/mlx5/linux/mlx5_common_os.c +131
-0@@ -11,6 +11,7 @@#endif #include <dirent.h> #include <net/if.h> +#include <fcntl.h> #include <rte_errno.h> #include <rte_string_fns.h> @@ -964,3 +965,133 @@claim_zero (mlx5_glue->dereg_mr (pmd_mr->obj));memset (pmd_mr,0 ,sizeof (*pmd_mr)); } + +/** +* Rte_intr_handle create and init helper. +* +* @param[in] mode +* interrupt instance can be shared between primary and secondary +* processes or not. +* @param[in] set_fd_nonblock +* Whether to set fd to O_NONBLOCK. +* @param[in] fd +* Fd to set in created intr_handle. +* @param[in] cb +* Callback to register for intr_handle. +* @param[in] cb_arg +* Callback argument for cb. +* +* @return +* - Interrupt handle on success. +* - NULL on failure, with rte_errno set. +*/ +struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg) +{ +struct rte_intr_handle *tmp_intr_handle; +int ret, flags; + + tmp_intr_handle =rte_intr_instance_alloc (mode); +if (!tmp_intr_handle) { + rte_errno =ENOMEM ; + goto err; + } +if (set_fd_nonblock) { + flags =fcntl (fd,F_GETFL ); + ret =fcntl (fd,F_SETFL , flags |O_NONBLOCK ); +if (ret) { + rte_errno = errno; + goto err; + } + } + ret =rte_intr_fd_set (tmp_intr_handle, fd); +if (ret) + goto err; + ret =rte_intr_type_set (tmp_intr_handle,RTE_INTR_HANDLE_EXT ); +if (ret) + goto err; + ret =rte_intr_callback_register (tmp_intr_handle, cb, cb_arg); +if (ret) { + rte_errno = -ret; + goto err; + } +return tmp_intr_handle; +err: +if (tmp_intr_handle) +rte_intr_instance_free (tmp_intr_handle); +return NULL ; +} + +/* Safe unregistration for interrupt callback. */ +static void +mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, +rte_intr_callback_fn cb_fn,void *cb_arg) +{ +uint64_t twait =0 ; +uint64_t start =0 ; + +do { +int ret; + + ret =rte_intr_callback_unregister (handle, cb_fn, cb_arg); +if (ret >=0 ) +return ; +if (ret != -EAGAIN ) { +DRV_LOG (INFO ,"failed to unregister interrupt" +" handler (error: %d)" , ret); +MLX5_ASSERT (false); +return ; + } +if (twait) { +struct timespec onems; + +/* Wait one millisecond and try again. */ + onems.tv_sec =0 ; + onems.tv_nsec =NS_PER_S /MS_PER_S ; +nanosleep (&onems,0 ); +/* Check whether one second elapsed. */ +if ((rte_get_timer_cycles () - start) <= twait) +continue ; + }else { +/* +* We get the amount of timer ticks for one second. +* If this amount elapsed it means we spent one +* second in waiting. This branch is executed once +* on first iteration. +*/ + twait =rte_get_timer_hz (); +MLX5_ASSERT (twait); + } +/* +* Timeout elapsed, show message (once a second) and retry. +* We have no other acceptable option here, if we ignore +* the unregistering return code the handler will not +* be unregistered, fd will be closed and we may get the +* crush. Hanging and messaging in the loop seems not to be +* the worst choice. +*/ +DRV_LOG (INFO ,"Retrying to unregister interrupt handler" ); + start =rte_get_timer_cycles (); + }while (true); +} + +/** +* Rte_intr_handle destroy helper. +* +* @param[in] intr_handle +* Rte_intr_handle to destroy. +* @param[in] cb +* Callback which is registered to intr_handle. +* @param[in] cb_arg +* Callback argument for cb. +* +*/ +void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg) +{ +if (rte_intr_fd_get (intr_handle) >=0 ) +mlx5_intr_callback_unregister (intr_handle, cb, cb_arg); +rte_intr_instance_free (intr_handle); +}drivers/common/mlx5/linux/mlx5_common_os.h +11
-0@@ -15,6 +15,7 @@#include <rte_log.h> #include <rte_kvargs.h> #include <rte_devargs.h> +#include <rte_interrupts.h> #include "mlx5_autoconf.h" #include "mlx5_glue.h" @@ -299,4 +300,14 @@int mlx5_get_device_guid (const struct rte_pci_addr *dev,uint8_t *guid,size_t len); +__rte_internal +struct rte_intr_handle * +mlx5_os_interrupt_handler_create (int mode,bool set_fd_nonblock,int fd, +rte_intr_callback_fn cb,void *cb_arg); + +__rte_internal +void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg); +#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */ drivers/common/mlx5/version.map +2
-0@@ -153,5 +153,7 @@ INTERNAL { mlx5_mr_mempool2mr_bh; mlx5_mr_mempool_populate_cache; + mlx5_os_interrupt_handler_create; # WINDOWS_NO_EXPORT + mlx5_os_interrupt_handler_destroy; # WINDOWS_NO_EXPORT local: *; };drivers/common/mlx5/windows/mlx5_common_os.h +1
-0@@ -9,6 +9,7 @@#include <sys/types.h> #include <rte_errno.h> +#include <rte_interrupts.h> #include "mlx5_autoconf.h" #include "mlx5_glue.h"
drivers/common/mlx5/windows/mlx5_common_os.h line 257
Quoted 4 lines
drivers/common/mlx5/windows/mlx5_common_os.h +1
-0@@ -253,4 +254,27 @@__rte_internal int mlx5_os_umem_dereg(void *pumem); +static inline struct rte_intr_handle *
Are you sure the static inline is required here, anywhere I see this called is from a function pointer?
Quoted 522 lines
drivers/common/mlx5/windows/mlx5_common_os.h +22
-0+mlx5_os_interrupt_handler_create(int mode, bool set_fd_nonblock, int fd, + rte_intr_callback_fn cb, void *cb_arg) +{ + (void)mode; + (void )set_fd_nonblock; + (void )fd; + (void )cb; + (void )cb_arg; + rte_errno =ENOTSUP ; +return NULL ; +} + +static inline void +mlx5_os_interrupt_handler_destroy (struct rte_intr_handle *intr_handle, +rte_intr_callback_fn cb,void *cb_arg) +{ + (void )intr_handle; + (void )cb; + (void )cb_arg; +} + +#endif /* RTE_PMD_MLX5_COMMON_OS_H_ */ drivers/net/mlx5/linux/mlx5_ethdev_os.c +0
-71@@ -881,77 +881,6 @@ struct ethtool_link_settings { } } -/* -* Unregister callback handler safely. The handler may be active -* while we are trying to unregister it, in this case code -EAGAIN -* is returned by rte_intr_callback_unregister(). This routine checks -* the return code and tries to unregister handler again. -* -* @param handle -* interrupt handle -* @param cb_fn -* pointer to callback routine -* @cb_arg -* opaque callback parameter -*/ -void -mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, -rte_intr_callback_fn cb_fn,void *cb_arg) -{ -/* -* Try to reduce timeout management overhead by not calling -* the timer related routines on the first iteration. If the -* unregistering succeeds on first call there will be no -* timer calls at all. -*/ -uint64_t twait =0 ; -uint64_t start =0 ; - -do { -int ret; - - ret =rte_intr_callback_unregister (handle, cb_fn, cb_arg); -if (ret >=0 ) -return ; -if (ret != -EAGAIN ) { -DRV_LOG (INFO ,"failed to unregister interrupt" -" handler (error: %d)" , ret); -MLX5_ASSERT (false); -return ; - } -if (twait) { -struct timespec onems; - -/* Wait one millisecond and try again. */ - onems.tv_sec =0 ; - onems.tv_nsec =NS_PER_S /MS_PER_S ; -nanosleep (&onems,0 ); -/* Check whether one second elapsed. */ -if ((rte_get_timer_cycles () - start) <= twait) -continue ; - }else { -/* -* We get the amount of timer ticks for one second. -* If this amount elapsed it means we spent one -* second in waiting. This branch is executed once -* on first iteration. -*/ - twait =rte_get_timer_hz (); -MLX5_ASSERT (twait); - } -/* -* Timeout elapsed, show message (once a second) and retry. -* We have no other acceptable option here, if we ignore -* the unregistering return code the handler will not -* be unregistered, fd will be closed and we may get the -* crush. Hanging and messaging in the loop seems not to be -* the worst choice. -*/ -DRV_LOG (INFO ,"Retrying to unregister interrupt handler" ); - start =rte_get_timer_cycles (); - }while (true); -} -/** * Handle DEVX interrupts from the NIC. * This function is probably called from the DPDK host thread. drivers/net/mlx5/linux/mlx5_os.c +29
-103@@ -2494,40 +2494,6 @@mlx5_pmd_socket_uninit (); } -static int -mlx5_os_dev_shared_handler_install_lsc (struct mlx5_dev_ctx_shared *sh) -{ -int nlsk_fd, flags, ret; - - nlsk_fd =mlx5_nl_init (NETLINK_ROUTE ,RTMGRP_LINK ); -if (nlsk_fd <0 ) { -DRV_LOG (ERR ,"Failed to create a socket for Netlink events: %s" , -rte_strerror (rte_errno)); -return -1 ; - } - flags =fcntl (nlsk_fd,F_GETFL ); - ret =fcntl (nlsk_fd,F_SETFL , flags |O_NONBLOCK ); -if (ret !=0 ) { -DRV_LOG (ERR ,"Failed to make Netlink event socket non-blocking: %s" , -strerror (errno)); - rte_errno = errno; - goto error; - } -rte_intr_type_set (sh->intr_handle_nl,RTE_INTR_HANDLE_EXT ); -rte_intr_fd_set (sh->intr_handle_nl, nlsk_fd); -if (rte_intr_callback_register (sh->intr_handle_nl, - mlx5_dev_interrupt_handler_nl, - sh) !=0 ) { -DRV_LOG (ERR ,"Failed to register Netlink events interrupt" ); -rte_intr_fd_set (sh->intr_handle_nl,-1 ); - goto error; - } -return 0 ; -error: -close (nlsk_fd); -return -1 ; -} -/** * Install shared asynchronous device events handler. * This function is implemented to support event sharing @@ -2539,76 +2505,47 @@void mlx5_os_dev_shared_handler_install (struct mlx5_dev_ctx_shared *sh) { -int ret; -int flags;struct ibv_context *ctx = sh->cdev->ctx; +int nlsk_fd; - sh->intr_handle =rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_SHARED ); -if (sh->intr_handle ==NULL ) { -DRV_LOG (ERR ,"Fail to allocate intr_handle" ); - rte_errno =ENOMEM ; + sh->intr_handle =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , true, + ctx->async_fd, mlx5_dev_interrupt_handler, sh); +if (!sh->intr_handle) { +DRV_LOG (ERR ,"Failed to allocate intr_handle." );return ; } -rte_intr_fd_set (sh->intr_handle,-1 ); - - flags =fcntl (ctx->async_fd,F_GETFL ); - ret =fcntl (ctx->async_fd,F_SETFL , flags |O_NONBLOCK ); -if (ret) { -DRV_LOG (INFO ,"failed to change file descriptor async event" -" queue" ); - }else { -rte_intr_fd_set (sh->intr_handle, ctx->async_fd); -rte_intr_type_set (sh->intr_handle,RTE_INTR_HANDLE_EXT ); -if (rte_intr_callback_register (sh->intr_handle, - mlx5_dev_interrupt_handler, sh)) { -DRV_LOG (INFO ,"Fail to install the shared interrupt." ); -rte_intr_fd_set (sh->intr_handle,-1 ); - } + nlsk_fd =mlx5_nl_init (NETLINK_ROUTE ,RTMGRP_LINK ); +if (nlsk_fd <0 ) { +DRV_LOG (ERR ,"Failed to create a socket for Netlink events: %s" , +rte_strerror (rte_errno)); +return ; } - sh->intr_handle_nl =rte_intr_instance_alloc - (RTE_INTR_INSTANCE_F_SHARED ); + sh->intr_handle_nl =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , true, + nlsk_fd, mlx5_dev_interrupt_handler_nl, sh);if (sh->intr_handle_nl ==NULL ) {DRV_LOG (ERR ,"Fail to allocate intr_handle" ); - rte_errno =ENOMEM ;return ; } -rte_intr_fd_set (sh->intr_handle_nl,-1 ); -if (mlx5_os_dev_shared_handler_install_lsc (sh) <0 ) { -DRV_LOG (INFO ,"Fail to install the shared Netlink event handler." ); -rte_intr_fd_set (sh->intr_handle_nl,-1 ); - }if (sh->cdev->config.devx) {#ifdef HAVE_IBV_DEVX_ASYNC - sh->intr_handle_devx = -rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_SHARED ); -if (!sh->intr_handle_devx) { -DRV_LOG (ERR ,"Fail to allocate intr_handle" ); - rte_errno =ENOMEM ; -return ; - } -rte_intr_fd_set (sh->intr_handle_devx,-1 ); +struct mlx5dv_devx_cmd_comp *devx_comp; + sh->devx_comp = (void *)mlx5_glue->devx_create_cmd_comp (ctx); -struct mlx5dv_devx_cmd_comp *devx_comp = sh->devx_comp; + devx_comp = sh->devx_comp;if (!devx_comp) {DRV_LOG (INFO ,"failed to allocate devx_comp." );return ; } - flags =fcntl (devx_comp->fd,F_GETFL ); - ret =fcntl (devx_comp->fd,F_SETFL , flags |O_NONBLOCK ); -if (ret) { -DRV_LOG (INFO ,"failed to change file descriptor" -" devx comp" ); + sh->intr_handle_devx =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , true, + devx_comp->fd, + mlx5_dev_interrupt_handler_devx, sh); +if (!sh->intr_handle_devx) { +DRV_LOG (ERR ,"Failed to allocate intr_handle." );return ; } -rte_intr_fd_set (sh->intr_handle_devx, devx_comp->fd); -rte_intr_type_set (sh->intr_handle_devx, -RTE_INTR_HANDLE_EXT ); -if (rte_intr_callback_register (sh->intr_handle_devx, - mlx5_dev_interrupt_handler_devx, sh)) { -DRV_LOG (INFO ,"Fail to install the devx shared" -" interrupt." ); -rte_intr_fd_set (sh->intr_handle_devx,-1 ); - }#endif /* HAVE_IBV_DEVX_ASYNC */ } }@@ -2624,24 +2561,13 @@void mlx5_os_dev_shared_handler_uninstall (struct mlx5_dev_ctx_shared *sh) { -int nlsk_fd; - -if (rte_intr_fd_get (sh->intr_handle) >=0 ) -mlx5_intr_callback_unregister (sh->intr_handle, - mlx5_dev_interrupt_handler, sh); -rte_intr_instance_free (sh->intr_handle); - nlsk_fd =rte_intr_fd_get (sh->intr_handle_nl); -if (nlsk_fd >=0 ) { -mlx5_intr_callback_unregister - (sh->intr_handle_nl, mlx5_dev_interrupt_handler_nl, sh); -close (nlsk_fd); - } -rte_intr_instance_free (sh->intr_handle_nl); +mlx5_os_interrupt_handler_destroy (sh->intr_handle, + mlx5_dev_interrupt_handler, sh); +mlx5_os_interrupt_handler_destroy (sh->intr_handle_nl, + mlx5_dev_interrupt_handler_nl, sh);#ifdef HAVE_IBV_DEVX_ASYNC -if (rte_intr_fd_get (sh->intr_handle_devx) >=0 ) -rte_intr_callback_unregister (sh->intr_handle_devx, - mlx5_dev_interrupt_handler_devx, sh); -rte_intr_instance_free (sh->intr_handle_devx); +mlx5_os_interrupt_handler_destroy (sh->intr_handle_devx, + mlx5_dev_interrupt_handler_devx, sh);if (sh->devx_comp) mlx5_glue->devx_destroy_cmd_comp (sh->devx_comp);#endif drivers/net/mlx5/linux/mlx5_socket.c +6
-47@@ -134,51 +134,6 @@ }/** -* Install interrupt handler. -* -* @param dev -* Pointer to Ethernet device. -* @return -* 0 on success, a negative errno value otherwise. -*/ -static int -mlx5_pmd_interrupt_handler_install (void ) -{ -MLX5_ASSERT (server_socket !=-1 ); - - server_intr_handle = -rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); -if (server_intr_handle ==NULL ) { -DRV_LOG (ERR ,"Fail to allocate intr_handle" ); -return -ENOMEM ; - } -if (rte_intr_fd_set (server_intr_handle, server_socket)) -return -rte_errno; - -if (rte_intr_type_set (server_intr_handle,RTE_INTR_HANDLE_EXT )) -return -rte_errno; - -return rte_intr_callback_register (server_intr_handle, - mlx5_pmd_socket_handle,NULL ); -} - -/** -* Uninstall interrupt handler. -*/ -static void -mlx5_pmd_interrupt_handler_uninstall (void ) -{ -if (server_socket !=-1 ) { -mlx5_intr_callback_unregister (server_intr_handle, - mlx5_pmd_socket_handle, -NULL ); - } -rte_intr_fd_set (server_intr_handle,0 ); -rte_intr_type_set (server_intr_handle,RTE_INTR_HANDLE_UNKNOWN ); -rte_intr_instance_free (server_intr_handle); -} - -/** * Initialise the socket to communicate with external tools. * * @return @@ -224,7 +179,10 @@ strerror(errno)); goto remove; } -if (mlx5_pmd_interrupt_handler_install ()) { + server_intr_handle =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_PRIVATE , false, + server_socket, mlx5_pmd_socket_handle,NULL ); +if (server_intr_handle ==NULL ) {DRV_LOG (WARNING ,"cannot register interrupt handler for mlx5 socket: %s" ,strerror (errno)); goto remove;@@ -248,7 +206,8 @@ {if (server_socket ==-1 )return ; -mlx5_pmd_interrupt_handler_uninstall (); +mlx5_os_interrupt_handler_destroy (server_intr_handle, + mlx5_pmd_socket_handle,NULL );claim_zero (close (server_socket)); server_socket =-1 ;MKSTR (path,MLX5_SOCKET_PATH ,getpid ());drivers/net/mlx5/mlx5.h +0
-2@@ -1682,8 +1682,6 @@ int mlx5_sysfs_switch_info(unsigned int ifindex, struct mlx5_switch_info *info);void mlx5_translate_port_name (const char *port_name_in,struct mlx5_switch_info *port_info_out); -void mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, -rte_intr_callback_fn cb_fn,void *cb_arg);int mlx5_sysfs_bond_info (unsigned int pf_ifindex,unsigned int *ifindex,char *ifname); int mlx5_get_module_info(struct rte_eth_dev *dev,drivers/net/mlx5/mlx5_txpp.c +7
-21@@ -741,11 +741,8 @@static void mlx5_txpp_stop_service (struct mlx5_dev_ctx_shared *sh) { -if (!rte_intr_fd_get (sh->txpp.intr_handle)) -return ; -mlx5_intr_callback_unregister (sh->txpp.intr_handle, - mlx5_txpp_interrupt_handler, sh); -rte_intr_instance_free (sh->txpp.intr_handle); +mlx5_os_interrupt_handler_destroy (sh->txpp.intr_handle, + mlx5_txpp_interrupt_handler, sh); }/* Attach interrupt handler and fires first request to Rearm Queue. */ @@ -769,23 +766,12 @@ rte_errno = errno;return -rte_errno; } - sh->txpp.intr_handle = -rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_SHARED ); -if (sh->txpp.intr_handle ==NULL ) { -DRV_LOG (ERR ,"Fail to allocate intr_handle" ); -return -ENOMEM ; - } fd =mlx5_os_get_devx_channel_fd (sh->txpp.echan); -if (rte_intr_fd_set (sh->txpp.intr_handle, fd)) -return -rte_errno; - -if (rte_intr_type_set (sh->txpp.intr_handle,RTE_INTR_HANDLE_EXT )) -return -rte_errno; - -if (rte_intr_callback_register (sh->txpp.intr_handle, - mlx5_txpp_interrupt_handler, sh)) { -rte_intr_fd_set (sh->txpp.intr_handle,0 ); -DRV_LOG (ERR ,"Failed to register CQE interrupt %d." , rte_errno); + sh->txpp.intr_handle =mlx5_os_interrupt_handler_create + (RTE_INTR_INSTANCE_F_SHARED , false, + fd, mlx5_txpp_interrupt_handler, sh); +if (!sh->txpp.intr_handle) { +DRV_LOG (ERR ,"Fail to allocate intr_handle" );return -rte_errno; }/* Subscribe CQ event to the event channel controlled by the driver. */ drivers/net/mlx5/windows/mlx5_ethdev_os.c +0
-22@@ -140,28 +140,6 @@return 0 ; } -/* -* Unregister callback handler safely. The handler may be active -* while we are trying to unregister it, in this case code -EAGAIN -* is returned by rte_intr_callback_unregister(). This routine checks -* the return code and tries to unregister handler again. -* -* @param handle -* interrupt handle -* @param cb_fn -* pointer to callback routine -* @cb_arg -* opaque callback parameter -*/ -void -mlx5_intr_callback_unregister (const struct rte_intr_handle *handle, -rte_intr_callback_fn cb_fn,void *cb_arg) -{ -RTE_SET_USED (handle); -RTE_SET_USED (cb_fn); -RTE_SET_USED (cb_arg); -} -/** * DPDK callback to get flow control status. * drivers/vdpa/mlx5/mlx5_vdpa_virtq.c +7
-41@@ -93,22 +93,10 @@static int mlx5_vdpa_virtq_unset (struct mlx5_vdpa_virtq *virtq) { -int ret = -EAGAIN ; - -if (rte_intr_fd_get (virtq->intr_handle) >=0 ) { -while (ret == -EAGAIN ) { - ret =rte_intr_callback_unregister (virtq->intr_handle, - mlx5_vdpa_virtq_kick_handler, virtq); -if (ret == -EAGAIN ) { -DRV_LOG (DEBUG ,"Try again to unregister fd %d of virtq %hu interrupt" , -rte_intr_fd_get (virtq->intr_handle), - virtq->index); -usleep (MLX5_VDPA_INTR_RETRIES_USEC ); - } - } -rte_intr_fd_set (virtq->intr_handle,-1 ); - } -rte_intr_instance_free (virtq->intr_handle); +int ret; + +mlx5_os_interrupt_handler_destroy (virtq->intr_handle, + mlx5_vdpa_virtq_kick_handler, virtq);if (virtq->virtq) { ret =mlx5_vdpa_virtq_stop (virtq->priv, virtq->index);if (ret)@@ -365,35 +353,13 @@ virtq->priv = priv;rte_write32 (virtq->index, priv->virtq_db_addr);/* Setup doorbell mapping. */ - virtq->intr_handle = -rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_SHARED ); + virtq->intr_handle =mlx5_os_interrupt_handler_create ( +RTE_INTR_INSTANCE_F_SHARED , false, + vq.kickfd, mlx5_vdpa_virtq_kick_handler, virtq);if (virtq->intr_handle ==NULL ) {DRV_LOG (ERR ,"Fail to allocate intr_handle" ); goto error; } - -if (rte_intr_fd_set (virtq->intr_handle, vq.kickfd)) - goto error; - -if (rte_intr_fd_get (virtq->intr_handle) ==-1 ) { -DRV_LOG (WARNING ,"Virtq %d kickfd is invalid." , index); - }else { -if (rte_intr_type_set (virtq->intr_handle,RTE_INTR_HANDLE_EXT )) - goto error; - -if (rte_intr_callback_register (virtq->intr_handle, - mlx5_vdpa_virtq_kick_handler, - virtq)) { -rte_intr_fd_set (virtq->intr_handle,-1 ); -DRV_LOG (ERR ,"Failed to register virtq %d interrupt." , - index); - goto error; - }else { -DRV_LOG (DEBUG ,"Register fd %d interrupt for virtq %d." , -rte_intr_fd_get (virtq->intr_handle), - index); - } - }/* Subscribe virtq error event. */ virtq->version++; cookie = ((uint64_t )virtq->version <<32 ) + index;
Signature · 1 line
Regards, Ray K