[1/2] node: forward packet from ethdev_rx node
Checks
Commit Message
By default all packets received on ethdev_rx node
is forwarded to pkt_cls node.This patch provides
library support to add a new node as next node to
ethdev_rx node and forward packet to new node from
rx node.
Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
---
lib/node/ethdev_ctrl.c | 40 +++++++++++++++++++++++++++++++++++++
lib/node/rte_node_eth_api.h | 17 ++++++++++++++++
lib/node/version.map | 1 +
3 files changed, 58 insertions(+)
Comments
> -----Original Message-----
> From: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> Sent: Thursday, November 23, 2023 11:46 AM
> To: Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; Pavan
> Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> Rakesh Kudurumalla <rkudurumalla@marvell.com>
> Subject: [EXT] [PATCH 1/2] node: forward packet from ethdev_rx node
>
> External Email
>
> ----------------------------------------------------------------------
> By default all packets received on ethdev_rx node is forwarded to pkt_cls
> node.This patch provides library support to add a new node as next node to
> ethdev_rx node and forward packet to new node from rx node.
>
IMO, Subject "node: add API to update ethdev_rx next node" or similar is more suitable to reflect the implementation.
Please run check-git-log.sh also to make sure that subject is aligned.
> Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
> ---
> lib/node/ethdev_ctrl.c | 40
> +++++++++++++++++++++++++++++++++++++
> lib/node/rte_node_eth_api.h | 17 ++++++++++++++++
> lib/node/version.map | 1 +
> 3 files changed, 58 insertions(+)
>
> diff --git a/lib/node/ethdev_ctrl.c b/lib/node/ethdev_ctrl.c index
> d564b80e37..d64fc33655 100644
> --- a/lib/node/ethdev_ctrl.c
> +++ b/lib/node/ethdev_ctrl.c
> @@ -129,3 +129,43 @@ rte_node_eth_config(struct
> rte_node_ethdev_config *conf, uint16_t nb_confs,
> ctrl.nb_graphs = nb_graphs;
> return 0;
> }
> +
> +int
> +rte_node_ethdev_rx_next_update(rte_node_t id, const char *edge_name) {
> + struct ethdev_rx_node_main *data;
> + ethdev_rx_node_elem_t *elem;
> + char **next_nodes;
> + int rc = -EINVAL;
> + uint32_t count;
> + uint16_t i = 0;
> +
> + if (id == RTE_EDGE_ID_INVALID)
> + return id;
Return type and returned value are mismatched.
> +
Add a NULL check for edge_name too.
> + count = rte_node_edge_get(id, NULL);
This API itself return error if id is invalid. Use returned value instead of above check.
> + next_nodes = malloc(count);
> + if (next_nodes == NULL)
> + return rc;
> +
> + count = rte_node_edge_get(id, next_nodes);
> +
> + while (next_nodes[i] != NULL) {
> + if (strcmp(edge_name, next_nodes[i]) == 0) {
> + data = ethdev_rx_get_node_data_get();
> + elem = data->head;
> + while (elem->next != data->head) {
> + if (elem->nid == id) {
> + elem->ctx.cls_next = i;
> + rc = 0;
> + goto found;
> + }
> + elem = elem->next;
> + }
> + }
> + i++;
> + }
> +found:
Cosmetic: use "exit" keyword instead of "found".
> + free(next_nodes);
> + return rc;
> +}
> diff --git a/lib/node/rte_node_eth_api.h b/lib/node/rte_node_eth_api.h index
> eaae50772d..66cea2d31e 100644
> --- a/lib/node/rte_node_eth_api.h
> +++ b/lib/node/rte_node_eth_api.h
> @@ -57,6 +57,23 @@ struct rte_node_ethdev_config {
> */
> int rte_node_eth_config(struct rte_node_ethdev_config *cfg,
> uint16_t cnt, uint16_t nb_graphs);
> +
> +/**
> + * Update ethdev rx next node.
> + *
> + * @param id
> + * Node id whose edge is to be updated.
> + * @param edge_name
> + * Name of the next node.
> + *
> + * @return
> + * RTE_EDGE_ID_INVALID if id is invalid
> + * EINVAL if edge name doesn't exist
> + * 0 on successful initialization.
> + */
Does it make sense to add error codes like below:
-ENINVAL: Either of input parameters are invalid.
-ENODATA: If edge_name is not found.
-ENOMEM: If memory allocation failed.
0: on Success
What's your thoughts on this ?
> +__rte_experimental
> +int rte_node_ethdev_rx_next_update(rte_node_t id, const char
> +*edge_name);
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/lib/node/version.map b/lib/node/version.map index
> 99ffcdd414..07abc3a79f 100644
> --- a/lib/node/version.map
> +++ b/lib/node/version.map
> @@ -16,6 +16,7 @@ EXPERIMENTAL {
> rte_node_ip6_route_add;
>
> # added in 23.11
> + rte_node_ethdev_rx_next_update;
> rte_node_ip4_reassembly_configure;
> rte_node_udp4_dst_port_add;
> rte_node_udp4_usr_node_add;
> --
> 2.25.1
@@ -129,3 +129,43 @@ rte_node_eth_config(struct rte_node_ethdev_config *conf, uint16_t nb_confs,
ctrl.nb_graphs = nb_graphs;
return 0;
}
+
+int
+rte_node_ethdev_rx_next_update(rte_node_t id, const char *edge_name)
+{
+ struct ethdev_rx_node_main *data;
+ ethdev_rx_node_elem_t *elem;
+ char **next_nodes;
+ int rc = -EINVAL;
+ uint32_t count;
+ uint16_t i = 0;
+
+ if (id == RTE_EDGE_ID_INVALID)
+ return id;
+
+ count = rte_node_edge_get(id, NULL);
+ next_nodes = malloc(count);
+ if (next_nodes == NULL)
+ return rc;
+
+ count = rte_node_edge_get(id, next_nodes);
+
+ while (next_nodes[i] != NULL) {
+ if (strcmp(edge_name, next_nodes[i]) == 0) {
+ data = ethdev_rx_get_node_data_get();
+ elem = data->head;
+ while (elem->next != data->head) {
+ if (elem->nid == id) {
+ elem->ctx.cls_next = i;
+ rc = 0;
+ goto found;
+ }
+ elem = elem->next;
+ }
+ }
+ i++;
+ }
+found:
+ free(next_nodes);
+ return rc;
+}
@@ -57,6 +57,23 @@ struct rte_node_ethdev_config {
*/
int rte_node_eth_config(struct rte_node_ethdev_config *cfg,
uint16_t cnt, uint16_t nb_graphs);
+
+/**
+ * Update ethdev rx next node.
+ *
+ * @param id
+ * Node id whose edge is to be updated.
+ * @param edge_name
+ * Name of the next node.
+ *
+ * @return
+ * RTE_EDGE_ID_INVALID if id is invalid
+ * EINVAL if edge name doesn't exist
+ * 0 on successful initialization.
+ */
+__rte_experimental
+int rte_node_ethdev_rx_next_update(rte_node_t id, const char *edge_name);
+
#ifdef __cplusplus
}
#endif
@@ -16,6 +16,7 @@ EXPERIMENTAL {
rte_node_ip6_route_add;
# added in 23.11
+ rte_node_ethdev_rx_next_update;
rte_node_ip4_reassembly_configure;
rte_node_udp4_dst_port_add;
rte_node_udp4_usr_node_add;