};
static inline bool
-is_valid_node(struct rte_rib_node *node)
+is_valid_node(const struct rte_rib_node *node)
{
return (node->flag & RTE_RIB_VALID_NODE) == RTE_RIB_VALID_NODE;
}
static inline bool
-is_right_node(struct rte_rib_node *node)
+is_right_node(const struct rte_rib_node *node)
{
return node->parent->right == node;
}
{
struct rte_rib_node *cur, *prev = NULL;
- if (rib == NULL) {
+ if (unlikely(rib == NULL)) {
rte_errno = EINVAL;
return NULL;
}
struct rte_rib_node *
rte_rib_lookup_exact(struct rte_rib *rib, uint32_t ip, uint8_t depth)
{
- if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
+ if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
rte_errno = EINVAL;
return NULL;
}
{
struct rte_rib_node *tmp, *prev = NULL;
- if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
+ if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
rte_errno = EINVAL;
return NULL;
}
uint32_t common_prefix;
uint8_t common_depth;
- if ((rib == NULL) || (depth > RIB_MAXDEPTH)) {
+ if (unlikely(rib == NULL || depth > RIB_MAXDEPTH)) {
rte_errno = EINVAL;
return NULL;
}
int
rte_rib_get_ip(const struct rte_rib_node *node, uint32_t *ip)
{
- if ((node == NULL) || (ip == NULL)) {
+ if (unlikely(node == NULL || ip == NULL)) {
rte_errno = EINVAL;
return -1;
}
int
rte_rib_get_depth(const struct rte_rib_node *node, uint8_t *depth)
{
- if ((node == NULL) || (depth == NULL)) {
+ if (unlikely(node == NULL || depth == NULL)) {
rte_errno = EINVAL;
return -1;
}
int
rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh)
{
- if ((node == NULL) || (nh == NULL)) {
+ if (unlikely(node == NULL || nh == NULL)) {
rte_errno = EINVAL;
return -1;
}
int
rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh)
{
- if (node == NULL) {
+ if (unlikely(node == NULL)) {
rte_errno = EINVAL;
return -1;
}
struct rte_mempool *node_pool;
/* Check user arguments. */
- if (name == NULL || conf == NULL || conf->max_nodes <= 0) {
+ if (unlikely(name == NULL || conf == NULL || conf->max_nodes <= 0)) {
rte_errno = EINVAL;
return NULL;
}
/* allocate tailq entry */
te = rte_zmalloc("RIB_TAILQ_ENTRY", sizeof(*te), 0);
- if (te == NULL) {
+ if (unlikely(te == NULL)) {
RTE_LOG(ERR, LPM,
"Can not allocate tailq entry for RIB %s\n", name);
rte_errno = ENOMEM;
/* Allocate memory to store the RIB data structures. */
rib = rte_zmalloc_socket(mem_name,
sizeof(struct rte_rib), RTE_CACHE_LINE_SIZE, socket_id);
- if (rib == NULL) {
+ if (unlikely(rib == NULL)) {
RTE_LOG(ERR, LPM, "RIB %s memory allocation failed\n", name);
rte_errno = ENOMEM;
goto free_te;
};
static inline bool
-is_valid_node(struct rte_rib6_node *node)
+is_valid_node(const struct rte_rib6_node *node)
{
return (node->flag & RTE_RIB_VALID_NODE) == RTE_RIB_VALID_NODE;
}
static inline bool
-is_right_node(struct rte_rib6_node *node)
+is_right_node(const struct rte_rib6_node *node)
{
return node->parent->right == node;
}
uint8_t tmp_ip[RTE_RIB6_IPV6_ADDR_SIZE];
int i;
- if ((rib == NULL) || (ip == NULL) || (depth > RIB6_MAXDEPTH)) {
+ if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
rte_errno = EINVAL;
return NULL;
}
uint8_t tmp_ip[RTE_RIB6_IPV6_ADDR_SIZE];
int i;
- if ((rib == NULL) || (ip == NULL) || (depth > RIB6_MAXDEPTH)) {
+ if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
rte_errno = EINVAL;
return NULL;
}
int i, d;
uint8_t common_depth, ip_xor;
- if (unlikely((rib == NULL) || (ip == NULL) ||
- (depth > RIB6_MAXDEPTH))) {
+ if (unlikely((rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH))) {
rte_errno = EINVAL;
return NULL;
}
rte_rib6_get_ip(const struct rte_rib6_node *node,
uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE])
{
- if ((node == NULL) || (ip == NULL)) {
+ if (unlikely(node == NULL || ip == NULL)) {
rte_errno = EINVAL;
return -1;
}
int
rte_rib6_get_depth(const struct rte_rib6_node *node, uint8_t *depth)
{
- if ((node == NULL) || (depth == NULL)) {
+ if (unlikely(node == NULL || depth == NULL)) {
rte_errno = EINVAL;
return -1;
}
int
rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh)
{
- if ((node == NULL) || (nh == NULL)) {
+ if (unlikely(node == NULL || nh == NULL)) {
rte_errno = EINVAL;
return -1;
}
int
rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh)
{
- if (node == NULL) {
+ if (unlikely(node == NULL)) {
rte_errno = EINVAL;
return -1;
}
struct rte_mempool *node_pool;
/* Check user arguments. */
- if (name == NULL || conf == NULL || conf->max_nodes <= 0) {
+ if (unlikely(name == NULL || conf == NULL || conf->max_nodes <= 0)) {
rte_errno = EINVAL;
return NULL;
}
/* allocate tailq entry */
te = rte_zmalloc("RIB6_TAILQ_ENTRY", sizeof(*te), 0);
- if (te == NULL) {
+ if (unlikely(te == NULL)) {
RTE_LOG(ERR, LPM,
"Can not allocate tailq entry for RIB6 %s\n", name);
rte_errno = ENOMEM;
/* Allocate memory to store the RIB6 data structures. */
rib = rte_zmalloc_socket(mem_name,
sizeof(struct rte_rib6), RTE_CACHE_LINE_SIZE, socket_id);
- if (rib == NULL) {
+ if (unlikely(rib == NULL)) {
RTE_LOG(ERR, LPM, "RIB6 %s memory allocation failed\n", name);
rte_errno = ENOMEM;
goto free_te;