LCOV - code coverage report
Current view: top level - root/contrail/vrouter/dpdk/n3k - vr_dpdk_n3k_routes.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 21 23 91.3 %
Date: 2026-08-03 02:19:58 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* SPDX-License-Identifier: BSD-2-Clause
       2             :  * Copyright(c) HCL TECHNOLOGIES LTD
       3             :  * Submitted on behalf of a third-party: Intel Corporation, a
       4             :  * Delaware corporation, having its principal place of business
       5             :  * at 2200 Mission College Boulevard,
       6             :  * Santa Clara, California 95052, USA
       7             :  */
       8             : 
       9             : #ifndef __VR_DPDK_N3K_ROUTE_H__
      10             : #define __VR_DPDK_N3K_ROUTE_H__
      11             : 
      12             : #include <rte_byteorder.h>
      13             : 
      14             : #include "vr_nexthop.h"
      15             : #include "vr_ip_mtrie.h"
      16             : #include "vr_datapath.h"
      17             : 
      18             : struct vr_n3k_offload_route_key {
      19             :     uint32_t vrf_id;
      20             :     enum vr_n3k_ip_type type;
      21             :     union vr_n3k_ip ip;
      22             : };
      23             : 
      24             : struct vr_n3k_offload_bridge_key {
      25             :     uint8_t mac[VR_ETHER_ALEN];
      26             :     uint32_t vrf_id;
      27             : };
      28             : 
      29             : struct vr_n3k_offload_bridge_value {
      30             :     uint32_t label;
      31             :     uint32_t nh_id;
      32             : };
      33             : 
      34             : struct vr_n3k_offload_route_value {
      35             :     uint32_t label;
      36             :     uint32_t nh_id;
      37             : };
      38             : 
      39             : static inline int
      40          20 : vr_dpdk_n3k_offload_route_find(struct vr_n3k_offload_route_key key,
      41             :     struct vr_n3k_offload_route_value *out_value) {
      42          20 :     bool ipv6_key = key.type == VR_N3K_IP_TYPE_IPV6;
      43          80 :     struct vr_route_req rtr = {
      44             :         .rtr_req = {
      45          20 :             .rtr_vrf_id = key.vrf_id,
      46          20 :             .rtr_family = ipv6_key ? AF_INET6 : AF_INET,
      47          20 :             .rtr_prefix_size = ipv6_key ? VR_IP6_ADDRESS_LEN : VR_IP_ADDRESS_LEN,
      48          20 :             .rtr_prefix_len = ipv6_key ? IP6_PREFIX_LEN : IP4_PREFIX_LEN,
      49             :             .rtr_prefix = ipv6_key ? (int8_t *)key.ip.ipv6 : (int8_t *)&key.ip.ipv4,
      50             :         },
      51             :     };
      52          20 :     struct vr_nexthop *nh = vr_inet_route_lookup(key.vrf_id, &rtr);
      53             : 
      54          20 :     if (!nh) {
      55           0 :         return -ENOENT;
      56             :     }
      57             : 
      58          20 :     out_value->nh_id = nh->nh_id;
      59          20 :     out_value->label = rtr.rtr_req.rtr_label;
      60             : 
      61          20 :     return 0;
      62             : }
      63             : 
      64             : static inline int
      65          52 : vr_dpdk_n3k_offload_bridge_find(const struct vr_n3k_offload_bridge_key *key,
      66             :     struct vr_n3k_offload_bridge_value *out_value) {
      67             : 
      68          52 :     struct vr_route_req rtr = {
      69             :         .rtr_req = {
      70          52 :             .rtr_vrf_id = key->vrf_id,
      71             :             .rtr_label_flags = 0,
      72             :             .rtr_index = VR_BE_INVALID_INDEX,
      73             :             .rtr_mac_size = VR_ETHER_ALEN,
      74          52 :             .rtr_mac = (int8_t*)&key->mac,
      75             :         }
      76             :     };
      77             : 
      78             :     /* Note: We're not handling multicast case specially, like
      79             :      * __vrouter_bridge_lookup does, as it's not supported by HW anyway */
      80             : 
      81          52 :     struct vr_nexthop* nh = vr_bridge_lookup(key->vrf_id, &rtr);
      82             : 
      83          52 :     if (!nh) {
      84           0 :         return -ENOENT;
      85             :     }
      86             : 
      87          52 :     out_value->nh_id = nh->nh_id;
      88          52 :     out_value->label = rtr.rtr_req.rtr_label;
      89             : 
      90          52 :     return 0;
      91             : }
      92             : 
      93             : #endif  // __VR_DPDK_N3K_ROUTE_H__

Generated by: LCOV version 1.14