Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpf: force inline functions #712

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bpf/grantedv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct grantedv2_state {
bool direct_if_possible;
};

static inline uint64_t
static __rte_always_inline uint64_t
grantedv2_init_inline(struct gk_bpf_init_ctx *ctx)
{
struct gk_bpf_cookie *cookie = init_ctx_to_cookie(ctx);
Expand All @@ -124,7 +124,7 @@ grantedv2_init_inline(struct gk_bpf_init_ctx *ctx)
return GK_BPF_INIT_RET_OK;
}

static inline uint64_t
static __rte_always_inline uint64_t
grantedv2_pkt_begin(const struct gk_bpf_pkt_ctx *ctx,
struct grantedv2_state *state, uint32_t pkt_len)
{
Expand All @@ -149,7 +149,7 @@ grantedv2_pkt_begin(const struct gk_bpf_pkt_ctx *ctx,
return GK_BPF_PKT_RET_FORWARD;
}

static inline uint64_t
static __rte_always_inline uint64_t
grantedv2_pkt_test_2nd_limit(struct grantedv2_state *state, uint32_t pkt_len)
{
state->budget2_byte -= pkt_len;
Expand All @@ -158,7 +158,7 @@ grantedv2_pkt_test_2nd_limit(struct grantedv2_state *state, uint32_t pkt_len)
return GK_BPF_PKT_RET_FORWARD;
}

static inline uint64_t
static __rte_always_inline uint64_t
grantedv2_pkt_end(struct gk_bpf_pkt_ctx *ctx, struct grantedv2_state *state)
{
uint8_t priority = PRIORITY_GRANTED;
Expand Down
5 changes: 3 additions & 2 deletions bpf/libicmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
#include <netinet/ip_icmp.h>
#include <netinet/icmp6.h>

#include <rte_common.h>
#include <rte_mbuf_core.h>

#include "gatekeeper_flow_bpf.h"

static inline uint64_t
static __rte_always_inline uint64_t
check_icmp(struct gk_bpf_pkt_ctx *ctx, struct rte_mbuf *pkt)
{
struct icmphdr *icmp_hdr;
Expand Down Expand Up @@ -58,7 +59,7 @@ check_icmp(struct gk_bpf_pkt_ctx *ctx, struct rte_mbuf *pkt)
return GK_BPF_PKT_RET_FORWARD;
}

static inline uint64_t
static __rte_always_inline uint64_t
check_icmp6(struct gk_bpf_pkt_ctx *ctx, struct rte_mbuf *pkt)
{
struct icmp6_hdr *icmp6_hdr;
Expand Down
18 changes: 9 additions & 9 deletions bpf/tcp-services.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ struct tcpsrv_state {
struct tcpsrv_ports ports;
};

static inline int64_t
static __rte_always_inline int64_t
reset_budget1(const struct tcpsrv_state *state)
{
return (int64_t)state->tx1_rate_kib_sec * 1024; /* 1024 B/KiB */
}

static inline void
static __rte_always_inline void
reset_budget2(struct tcpsrv_state *state)
{
state->budget2_byte = reset_budget1(state) * 5 / 100; /* 5% */
Expand Down Expand Up @@ -151,7 +151,7 @@ tcpsrv_init(struct gk_bpf_init_ctx *ctx)
return GK_BPF_INIT_RET_OK;
}

static inline uint64_t
static __rte_always_inline uint64_t
tcpsrv_pkt_begin(const struct gk_bpf_pkt_ctx *ctx,
struct tcpsrv_state *state, uint32_t pkt_len)
{
Expand All @@ -176,7 +176,7 @@ tcpsrv_pkt_begin(const struct gk_bpf_pkt_ctx *ctx,
return GK_BPF_PKT_RET_FORWARD;
}

static inline uint64_t
static __rte_always_inline uint64_t
tcpsrv_pkt_test_2nd_limit(struct tcpsrv_state *state, uint32_t pkt_len)
{
state->budget2_byte -= pkt_len;
Expand All @@ -185,7 +185,7 @@ tcpsrv_pkt_test_2nd_limit(struct tcpsrv_state *state, uint32_t pkt_len)
return GK_BPF_PKT_RET_FORWARD;
}

static inline uint64_t
static __rte_always_inline uint64_t
tcpsrv_pkt_end(struct gk_bpf_pkt_ctx *ctx, struct tcpsrv_state *state)
{
uint8_t priority = PRIORITY_GRANTED;
Expand All @@ -208,7 +208,7 @@ tcpsrv_pkt_end(struct gk_bpf_pkt_ctx *ctx, struct tcpsrv_state *state)
break
#define FORWARD ports++

static inline bool
static __rte_always_inline bool
is_port_listed_forward(const uint16_t *ports, uint8_t count, uint16_t port)
{
RTE_BUILD_BUG_ON(TCPSRV_MAX_NUM_PORTS != 12);
Expand All @@ -233,7 +233,7 @@ is_port_listed_forward(const uint16_t *ports, uint8_t count, uint16_t port)
return *ports == port;
}

static inline bool
static __rte_always_inline bool
is_listening_port(struct tcpsrv_state *state, uint16_t port_be)
{
return is_port_listed_forward(&state->ports.p[0],
Expand All @@ -242,7 +242,7 @@ is_listening_port(struct tcpsrv_state *state, uint16_t port_be)

#define BACK ports--

static inline bool
static __rte_always_inline bool
is_port_listed_back(const uint16_t *ports, uint8_t count, uint16_t port)
{
RTE_BUILD_BUG_ON(TCPSRV_MAX_NUM_PORTS != 12);
Expand All @@ -267,7 +267,7 @@ is_port_listed_back(const uint16_t *ports, uint8_t count, uint16_t port)
return *ports == port;
}

static inline bool
static __rte_always_inline bool
is_remote_port(struct tcpsrv_state *state, uint16_t port_be)
{
return is_port_listed_back(&state->ports.p[TCPSRV_MAX_NUM_PORTS - 1],
Expand Down