MCPcopy Create free account
hub / github.com/F-Stack/f-stack / __rte_node_register

Function __rte_node_register

dpdk/lib/graph/node.c:57–116  ·  view source on GitHub ↗

Public functions */

Source from the content-addressed store, hash-verified

55
56/* Public functions */
57rte_node_t
58__rte_node_register(const struct rte_node_register *reg)
59{
60 struct node *node;
61 rte_edge_t i;
62 size_t sz;
63
64 /* Limit Node specific metadata to one cacheline on 64B CL machine */
65 RTE_BUILD_BUG_ON((offsetof(struct rte_node, nodes) -
66 offsetof(struct rte_node, ctx)) !=
67 RTE_CACHE_LINE_MIN_SIZE);
68
69 graph_spinlock_lock();
70
71 /* Check sanity */
72 if (reg == NULL || reg->process == NULL) {
73 rte_errno = EINVAL;
74 goto fail;
75 }
76
77 /* Check for duplicate name */
78 if (node_has_duplicate_entry(reg->name))
79 goto fail;
80
81 sz = sizeof(struct node) + (reg->nb_edges * RTE_NODE_NAMESIZE);
82 node = calloc(1, sz);
83 if (node == NULL) {
84 rte_errno = ENOMEM;
85 goto fail;
86 }
87
88 /* Initialize the node */
89 if (rte_strscpy(node->name, reg->name, RTE_NODE_NAMESIZE) < 0)
90 goto free;
91 node->flags = reg->flags;
92 node->process = reg->process;
93 node->init = reg->init;
94 node->fini = reg->fini;
95 node->nb_edges = reg->nb_edges;
96 node->parent_id = reg->parent_id;
97 for (i = 0; i < reg->nb_edges; i++) {
98 if (rte_strscpy(node->next_nodes[i], reg->next_nodes[i],
99 RTE_NODE_NAMESIZE) < 0)
100 goto free;
101 }
102
103 node->lcore_id = RTE_MAX_LCORE;
104 node->id = node_id++;
105
106 /* Add the node at tail */
107 STAILQ_INSERT_TAIL(&node_list, node, next);
108 graph_spinlock_unlock();
109
110 return node->id;
111free:
112 free(node);
113fail:
114 graph_spinlock_unlock();

Callers 1

node_cloneFunction · 0.85

Calls 6

graph_spinlock_lockFunction · 0.85
node_has_duplicate_entryFunction · 0.85
callocFunction · 0.85
rte_strscpyFunction · 0.85
graph_spinlock_unlockFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected