Skip to content

Commit

Permalink
Changed rte_flow helpers into inlines
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueCZ committed Aug 25, 2023
1 parent 1cb93ff commit 572eff4
Show file tree
Hide file tree
Showing 6 changed files with 558 additions and 665 deletions.
181 changes: 3 additions & 178 deletions include/rte_flow/dp_rte_flow.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __INCLUDE_DP_RTE_FLOW_H
#define __INCLUDE_DP_RTE_FLOW_H
#ifndef __INCLUDE_DP_RTE_FLOW_H__
#define __INCLUDE_DP_RTE_FLOW_H__

#ifdef __cplusplus
extern "C"
Expand Down Expand Up @@ -31,27 +31,12 @@ extern "C"
#define DP_IP_ICMP_CODE_DST_PORT_UNREACHABLE 3
#define DP_IP_ICMP_CODE_FRAGMENT_NEEDED 4

#define DP_TCP_CONTROL_FLAGS \
(RTE_TCP_FIN_FLAG|RTE_TCP_SYN_FLAG|RTE_TCP_RST_FLAG)

struct dp_icmp_err_ip_info {
struct rte_ipv4_hdr *err_ipv4_hdr;
rte_be16_t l4_src_port;
rte_be16_t l4_dst_port;
};

union dp_flow_item_l3 {
struct rte_flow_item_ipv4 ipv4;
struct rte_flow_item_ipv6 ipv6;
};

union dp_flow_item_l4 {
struct rte_flow_item_tcp tcp;
struct rte_flow_item_udp udp;
struct rte_flow_item_icmp icmp;
struct rte_flow_item_icmp6 icmp6;
};

uint16_t extract_inner_ethernet_header(struct rte_mbuf *pkt);
uint16_t extract_outer_ethernet_header(struct rte_mbuf *pkt);
int extract_inner_l3_header(struct rte_mbuf *pkt, void *hdr, uint16_t offset); // offset, ipv4/ipv6 header
Expand All @@ -67,166 +52,6 @@ void dp_change_icmp_err_l4_src_port(struct rte_mbuf *m, struct dp_icmp_err_ip_in
void dp_change_l4_hdr_port(struct rte_mbuf *m, uint8_t port_type, uint16_t new_val);
void dp_change_icmp_identifier(struct rte_mbuf *m, uint16_t new_val);

// functions to craft actions/patterns are added later

void dp_set_eth_flow_item(struct rte_flow_item *item,
struct rte_flow_item_eth *eth_spec,
rte_be16_t type);

void dp_set_eth_dst_flow_item(struct rte_flow_item *item,
struct rte_flow_item_eth *eth_spec,
const struct rte_ether_addr *dst,
rte_be16_t type);

void dp_set_eth_src_dst_flow_item(struct rte_flow_item *item,
struct rte_flow_item_eth *eth_spec,
const struct rte_ether_addr *src,
const struct rte_ether_addr *dst,
rte_be16_t type);

void dp_set_ipv6_flow_item(struct rte_flow_item *item,
struct rte_flow_item_ipv6 *ipv6_spec,
uint8_t proto);

void dp_set_ipv6_src_flow_item(struct rte_flow_item *item,
struct rte_flow_item_ipv6 *ipv6_spec,
const uint8_t *src,
uint8_t proto);

void dp_set_ipv6_dst_flow_item(struct rte_flow_item *item,
struct rte_flow_item_ipv6 *ipv6_spec,
const uint8_t *dst,
uint8_t proto);

void dp_set_ipv4_dst_flow_item(struct rte_flow_item *item,
struct rte_flow_item_ipv4 *ipv4_spec,
rte_be32_t dst,
uint8_t proto);

void dp_set_ipv4_src_dst_flow_item(struct rte_flow_item *item,
struct rte_flow_item_ipv4 *ipv4_spec,
rte_be32_t src,
rte_be32_t dst,
uint8_t proto);

void dp_set_udp_src_flow_item(struct rte_flow_item *item,
struct rte_flow_item_udp *udp_spec,
rte_be16_t src_port);

void dp_set_udp_src_dst_flow_item(struct rte_flow_item *item,
struct rte_flow_item_udp *udp_spec,
rte_be16_t src_port,
rte_be16_t dst_port);

void dp_set_tcp_src_flow_item(struct rte_flow_item *item,
struct rte_flow_item_tcp *tcp_spec,
rte_be16_t src_port);

void dp_set_tcp_src_dst_flow_item(struct rte_flow_item *item,
struct rte_flow_item_tcp *tcp_spec,
rte_be16_t src_port,
rte_be16_t dst_port);

void dp_set_tcp_src_dst_noctrl_flow_item(struct rte_flow_item *item,
struct rte_flow_item_tcp *tcp_spec,
rte_be16_t src_port,
rte_be16_t dst_port);

void dp_set_icmp_flow_item(struct rte_flow_item *item,
struct rte_flow_item_icmp *icmp_spec,
uint8_t type);

void dp_set_icmp6_flow_item(struct rte_flow_item *item,
struct rte_flow_item_icmp6 *icmp6_spec,
uint8_t type);

void dp_set_mark_flow_item(struct rte_flow_item *item,
struct rte_flow_item_mark *mark_spec,
uint32_t marked_id);

void dp_set_tag_flow_item(struct rte_flow_item *item,
struct rte_flow_item_tag *tag_spec,
uint32_t tag_value,
uint8_t tag_index);

void dp_set_meta_flow_item(struct rte_flow_item *item,
struct rte_flow_item_meta *meta_spec,
uint32_t meta_value);

void dp_set_end_flow_item(struct rte_flow_item *item);

int dp_set_l4_flow_item(struct rte_flow_item *item,
union dp_flow_item_l4 *l4_spec,
const struct dp_flow *df);


void dp_set_raw_decap_action(struct rte_flow_action *action,
struct rte_flow_action_raw_decap *raw_decap_action,
uint8_t *data_to_decap, size_t data_len);

void dp_set_raw_encap_action(struct rte_flow_action *action,
struct rte_flow_action_raw_encap *raw_encap_action,
uint8_t *data_to_encap, size_t data_len);

void dp_set_dst_mac_set_action(struct rte_flow_action *action,
struct rte_flow_action_set_mac *dst_mac_set_action,
const struct rte_ether_addr *dst_mac);

void dp_set_src_mac_set_action(struct rte_flow_action *action,
struct rte_flow_action_set_mac *src_mac_set_action,
const struct rte_ether_addr *src_mac);

void dp_set_ipv4_set_src_action(struct rte_flow_action *action,
struct rte_flow_action_set_ipv4 *ipv4_action,
rte_be32_t ipv4);

void dp_set_ipv4_set_dst_action(struct rte_flow_action *action,
struct rte_flow_action_set_ipv4 *ipv4_action,
rte_be32_t ipv4);

void dp_set_ipv6_set_src_action(struct rte_flow_action *action,
struct rte_flow_action_set_ipv6 *ipv6_action,
const uint8_t *ipv6);

void dp_set_ipv6_set_dst_action(struct rte_flow_action *action,
struct rte_flow_action_set_ipv6 *ipv6_action,
const uint8_t *ipv6);

void dp_set_trans_proto_set_src_action(struct rte_flow_action *action,
struct rte_flow_action_set_tp *tp_action,
rte_be16_t port);

void dp_set_trans_proto_set_dst_action(struct rte_flow_action *action,
struct rte_flow_action_set_tp *tp_action,
rte_be16_t port);

void dp_set_send_to_port_action(struct rte_flow_action *action,
struct rte_flow_action_port_id *send_to_port_action,
uint32_t port_id);

void dp_set_flow_age_action(struct rte_flow_action *action,
struct rte_flow_action_age *flow_age_action,
uint32_t timeout, void *age_context);

void dp_set_redirect_queue_action(struct rte_flow_action *action,
struct rte_flow_action_queue *queue_action,
uint16_t queue_index);

void dp_set_packet_mark_action(struct rte_flow_action *action,
struct rte_flow_action_mark *mark_action,
uint32_t marked_value);

void dp_set_set_tag_action(struct rte_flow_action *action,
struct rte_flow_action_set_tag *set_tag_action,
uint32_t tag_value);

void dp_set_set_meta_action(struct rte_flow_action *action,
struct rte_flow_action_set_meta *meta_action,
uint32_t meta_value);

void dp_set_end_action(struct rte_flow_action *action);


int dp_destroy_rte_action_handle(uint16_t port_id, struct rte_flow_action_handle *handle, struct rte_flow_error *error);

struct rte_flow *dp_install_rte_flow(uint16_t port_id,
Expand All @@ -244,4 +69,4 @@ int dp_create_age_indirect_action(uint16_t port_id,
}
#endif

#endif /* __INCLUDE_DP_RTE_FLOW_H */
#endif
Loading

0 comments on commit 572eff4

Please sign in to comment.