]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: changes for code maintainability 15409/head
authorsri-mohan1 <sri.mohan@samsung.com>
Thu, 22 Feb 2024 05:03:47 +0000 (10:33 +0530)
committersri-mohan1 <sri.mohan@samsung.com>
Thu, 22 Feb 2024 06:36:47 +0000 (12:06 +0530)
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
zebra/dpdk/zebra_dplane_dpdk.c

index 4c320442512e317a44626dd56996023be6be0c79..7a5388c57bb79a90ef7b571b662788b0afe901c8 100644 (file)
@@ -105,8 +105,7 @@ static int zd_dpdk_pbr_show_rules_walkcb(struct hash_bucket *bucket, void *arg)
                        ifp = if_lookup_by_name_vrf(rule->ifname, vrf);
 
                if (ifp)
-                       zd_dpdk_flow_stat_show(vty, ifp->ifindex,
-                                              zaction->dp_flow_ptr);
+                       zd_dpdk_flow_stat_show(vty, ifp->ifindex, zaction->dp_flow_ptr);
        }
        return HASHWALK_CONTINUE;
 }
@@ -153,8 +152,7 @@ static void zd_dpdk_rule_add(struct zebra_dplane_ctx *ctx)
                if (IS_ZEBRA_DEBUG_DPLANE_DPDK_DETAIL)
                        zlog_debug(
                                "PBR dpdk flow create ifname %s seq %d pri %u unique %d failed; in_port %d missing\n",
-                               dplane_ctx_rule_get_ifname(ctx), seq, pri,
-                               unique, in_ifindex);
+                               dplane_ctx_rule_get_ifname(ctx), seq, pri, unique, in_ifindex);
                return;
        }
 
@@ -163,8 +161,7 @@ static void zd_dpdk_rule_add(struct zebra_dplane_ctx *ctx)
                if (IS_ZEBRA_DEBUG_DPLANE_DPDK_DETAIL)
                        zlog_debug(
                                "PBR dpdk flow create ifname %s seq %d pri %u unique %d failed; out_port %d missing\n",
-                               dplane_ctx_rule_get_ifname(ctx), seq, pri,
-                               unique, out_ifindex);
+                               dplane_ctx_rule_get_ifname(ctx), seq, pri, unique, out_ifindex);
                return;
        }
 
@@ -180,7 +177,7 @@ static void zd_dpdk_rule_add(struct zebra_dplane_ctx *ctx)
 
        memset(&ip, 0, sizeof(ip));
        memset(&ip_mask, 0, sizeof(ip_mask));
-       if (filter_bm & PBR_FILTER_SRC_IP) {
+       if (CHECK_FLAG(filter_bm, PBR_FILTER_SRC_IP)) {
                const struct prefix *src_ip;
 
                src_ip = dplane_ctx_rule_get_src_ip(ctx);
@@ -188,7 +185,7 @@ static void zd_dpdk_rule_add(struct zebra_dplane_ctx *ctx)
                masklen2ip(src_ip->prefixlen, &tmp_mask);
                ip_mask.hdr.src_addr = tmp_mask.s_addr;
        }
-       if (filter_bm & PBR_FILTER_DST_IP) {
+       if (CHECK_FLAG(filter_bm, PBR_FILTER_DST_IP)) {
                const struct prefix *dst_ip;
 
                dst_ip = dplane_ctx_rule_get_dst_ip(ctx);
@@ -196,7 +193,7 @@ static void zd_dpdk_rule_add(struct zebra_dplane_ctx *ctx)
                masklen2ip(dst_ip->prefixlen, &tmp_mask);
                ip_mask.hdr.dst_addr = tmp_mask.s_addr;
        }
-       if (filter_bm & PBR_FILTER_IP_PROTOCOL) {
+       if (CHECK_FLAG(filter_bm, PBR_FILTER_IP_PROTOCOL)) {
                ip.hdr.next_proto_id = dplane_ctx_rule_get_ipproto(ctx);
                ip_mask.hdr.next_proto_id = UINT8_MAX;
        }
@@ -206,17 +203,15 @@ static void zd_dpdk_rule_add(struct zebra_dplane_ctx *ctx)
        items[item_cnt].last = NULL;
        ++item_cnt;
 
-       if ((filter_bm & (PBR_FILTER_SRC_PORT | PBR_FILTER_DST_PORT))) {
+       if (CHECK_FLAG(filter_bm, (PBR_FILTER_SRC_PORT | PBR_FILTER_DST_PORT))) {
                memset(&udp, 0, sizeof(udp));
                memset(&udp_mask, 0, sizeof(udp_mask));
-               if (filter_bm & PBR_FILTER_SRC_PORT) {
-                       udp.hdr.src_port =
-                               RTE_BE16(dplane_ctx_rule_get_src_port(ctx));
+               if (CHECK_FLAG(filter_bm, PBR_FILTER_SRC_PORT)) {
+                       udp.hdr.src_port = RTE_BE16(dplane_ctx_rule_get_src_port(ctx));
                        udp_mask.hdr.src_port = UINT16_MAX;
                }
-               if (filter_bm & PBR_FILTER_DST_PORT) {
-                       udp.hdr.dst_port =
-                               RTE_BE16(dplane_ctx_rule_get_dst_port(ctx));
+               if (CHECK_FLAG(filter_bm, PBR_FILTER_DST_PORT)) {
+                       udp.hdr.dst_port = RTE_BE16(dplane_ctx_rule_get_dst_port(ctx));
                        udp_mask.hdr.dst_port = UINT16_MAX;
                }
                items[item_cnt].type = RTE_FLOW_ITEM_TYPE_UDP;
@@ -273,8 +268,7 @@ static void zd_dpdk_rule_add(struct zebra_dplane_ctx *ctx)
        } else {
                zlog_warn(
                        "PBR dpdk flow create failed ifname %s seq %d pri %u unique %d; rc %d\n",
-                       dplane_ctx_rule_get_ifname(ctx), seq, pri, unique,
-                       error.type);
+                       dplane_ctx_rule_get_ifname(ctx), seq, pri, unique, error.type);
        }
 }
 
@@ -562,7 +556,7 @@ void zd_dpdk_port_show(struct vty *vty, uint16_t port_id, bool uj, int detail)
 
        for (count = 0; count < RTE_MAX_ETHPORTS; ++count) {
                dport = &dpdk_ctx->dpdk_ports[count];
-               if (dport->flags & ZD_DPDK_PORT_FLAG_INITED)
+               if (CHECK_FLAG(dport->flags, ZD_DPDK_PORT_FLAG_INITED))
                        zd_dpdk_port_show_entry(dport, vty, detail);
        }
 }
@@ -592,14 +586,14 @@ static void zd_dpdk_port_init(void)
                dport = &dpdk_ctx->dpdk_ports[count];
                count++;
                dport->port_id = port_id;
-               dport->flags |= ZD_DPDK_PORT_FLAG_PROBED;
+               SET_FLAG(dport->flags, ZD_DPDK_PORT_FLAG_PROBED);
                dev_info = &dport->dev_info;
                if (rte_eth_dev_info_get(port_id, dev_info) < 0) {
                        zlog_warn("failed to get dev info for %u, %s", port_id,
                                  rte_strerror(rte_errno));
                        continue;
                }
-               dport->flags |= ZD_DPDK_PORT_FLAG_INITED;
+               SET_FLAG(dport->flags, ZD_DPDK_PORT_FLAG_INITED);
                if (IS_ZEBRA_DEBUG_DPLANE_DPDK)
                        zlog_debug(
                                "port %u, dev %s, ifI %d, sw_name %s, sw_domain %u, sw_port %u",
@@ -611,12 +605,10 @@ static void zd_dpdk_port_init(void)
                if (rte_flow_isolate(port_id, 1, &error)) {
                        if (IS_ZEBRA_DEBUG_DPLANE_DPDK)
                                zlog_debug(
-                                       "Flow isolate on port %u failed %d",
-                                       port_id, error.type);
+                                       "Flow isolate on port %u failed %d", port_id, error.type);
                } else {
                        if (IS_ZEBRA_DEBUG_DPLANE_DPDK)
-                               zlog_debug("Flow isolate on port %u",
-                                          port_id);
+                               zlog_debug("Flow isolate on port %u", port_id);
                }
                rc = rte_eth_dev_start(port_id);
                if (rc) {
@@ -625,8 +617,7 @@ static void zd_dpdk_port_init(void)
                        continue;
                }
                if (IS_ZEBRA_DEBUG_DPLANE_DPDK)
-                       zlog_debug("DPDK port %d started in promiscuous mode ",
-                                  port_id);
+                       zlog_debug("DPDK port %d started in promiscuous mode ", port_id);
        }
 
        if (!count) {
@@ -639,8 +630,7 @@ static void zd_dpdk_port_init(void)
 static int zd_dpdk_init(void)
 {
        int rc;
-       static const char *argv[] = {(char *)"/usr/lib/frr/zebra",
-                                    (char *)"--"};
+       static const char *argv[] = {(char *)"/usr/lib/frr/zebra", (char *)"--"};
 
        zd_dpdk_vty_init();
 
@@ -674,8 +664,7 @@ static int zd_dpdk_finish(struct zebra_dplane_provider *prov, bool early)
 
        if (early) {
                if (IS_ZEBRA_DEBUG_DPLANE_DPDK)
-                       zlog_debug("%s early finish",
-                                  dplane_provider_get_name(prov));
+                       zlog_debug("%s early finish", dplane_provider_get_name(prov));
 
                return 0;
        }