2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #ifndef __INCLUDE_PIPELINE_LOADB_BE_H__
18 #define __INCLUDE_PIPELINE_LOADB_BE_H__
21 #include "pipeline_common_be.h"
24 #define MBUF_HDR_ROOM 256
25 #define ETH_HDR_SIZE 14
26 #define IP_HDR_SRC_ADR_OFST 12
27 #define IP_HDR_DST_ADR_OFST 16
28 #define IP_HDR_PROTOCOL_OFST 9
29 #define IP_HDR_SIZE 20
30 #define IPV6_HDR_SRC_ADR_OFST 8
31 #define IPV6_HDR_DST_ADR_OFST 24
32 #define IPV6_HDR_PROTOCOL_OFST 6
33 #define IPV6_HDR_SIZE 40
34 #define IP_PROTOCOL_TCP 6
35 #define IP_PROTOCOL_UDP 17
36 #define PIPELINE_LOADB_KEY_MAX_SIZE 64
38 #define LOADB_ING_DIR 0
39 #define LOADB_EGR_DIR 1
41 #define LOADB_DBG_CMD_OFST 8
42 #define LOADB_DBG_CMD_STATS_SHOW 0
43 #define LOADB_DBG_CMD_STATS_CLEAR 1
44 #define LOADB_DBG_CMD_DBG_LEVEL 2
45 #define LOADB_DBG_CMD_DBG_SHOW 3
46 #define LOADB_DBG_CMD_IF_STATS 4
47 #define LOADB_DBG_CMD_OFST1 10
49 #define PIPELINE_LOADB_KEY_PORT_IN_AH(f_ah, f_pkt_work, f_pkt4_work) \
52 __rte_unused struct rte_pipeline *rte_p, \
53 struct rte_mbuf **pkts, \
59 for (j = 0; j < n_pkts; j++) \
60 rte_prefetch0(pkts[j]); \
62 for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
63 f_pkt4_work(&pkts[i], i, arg); \
65 for ( ; i < n_pkts; i++) \
66 f_pkt_work(pkts[i], i, arg); \
72 extern uint8_t LOADB_DEBUG;
73 extern uint8_t in_port_egress_prv[PIPELINE_MAX_PORT_IN];
74 extern uint8_t prv_que_port_index[PIPELINE_MAX_PORT_IN];
75 extern uint8_t in_port_dir_a[PIPELINE_MAX_PORT_IN];
77 extern uint8_t get_in_port_dir(uint8_t);
78 extern uint8_t is_port_index_privte(uint16_t);
79 extern uint8_t is_phy_port_privte(uint16_t);
80 extern uint32_t get_prv_to_pub_port(uint32_t *ip_addr, uint8_t type);
81 extern uint32_t get_pub_to_prv_port(uint32_t *ip_addr, uint8_t type);
82 extern uint8_t prv_to_pub_map[PIPELINE_MAX_PORT_IN];
83 //extern struct app_params *myApp;
84 //extern struct pipeline_arpicmp *p_arp;
90 struct pipeline_loadb_in_port_h_arg {
91 struct pipeline_loadb *p;
98 enum pipeline_loadb_msg_req_type {
99 /* to be used for debug purposes */
100 PIPELINE_LOADB_MSG_REQ_ENTRY_DBG,
101 PIPELINE_LOADB_MSG_REQS
107 struct pipeline_loadb_entry_dbg_msg_req {
108 enum pipeline_msg_req_type type;
109 enum pipeline_loadb_msg_req_type subtype;
115 struct pipeline_loadb_entry_dbg_msg_rsp {
120 extern struct pipeline_be_ops pipeline_loadb_be_ops;
121 struct ipv4_hdr_port {
122 struct ipv4_hdr ipv4;
126 } __attribute__((__packed__));
127 struct ipv6_hdr_port {
128 struct ipv6_hdr ipv6;
132 } __attribute__((__packed__));
135 struct ether_hdr eth;
137 struct ipv4_hdr_port ipv4_port;
138 struct ipv6_hdr_port ipv6_port;
140 } __attribute__((__packed__));
142 uint8_t calculate_lb_thread_prv(struct rte_mbuf *pkt, void *arg);
143 uint8_t calculate_lb_thread_pub(struct rte_mbuf *pkt, void *arg);
144 int check_loadb_thread(
145 struct app_params *app,
146 struct pipeline_params *params,
147 int32_t n_vnf_threads);