summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/bp_sim.h3
-rw-r--r--src/dpdk/drivers/net/mlx5/mlx5_fdir.c18
-rw-r--r--src/main_dpdk.cpp32
-rw-r--r--src/pkt_gen.cpp18
4 files changed, 45 insertions, 26 deletions
diff --git a/src/bp_sim.h b/src/bp_sim.h
index 4899644b..e3dab2ad 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -80,6 +80,7 @@ typedef struct {
/* reserve both 0xFF and 0xFE , router will -1 FF */
#define TTL_RESERVE_DUPLICATE 0xff
+#define TOS_TTL_RESERVE_DUPLICATE 0x1
/*
* Length of string needed to hold the largest port (16-bit) address
@@ -3059,6 +3060,8 @@ inline void CFlowPktInfo::update_pkt_info(char *p,
printf(" %.3f : DP : learn packet !\n",now_sec());
#endif
ipv4->setTimeToLive(TTL_RESERVE_DUPLICATE);
+ ipv4->setTOS(0x3);
+
/* first ipv4 option add the info in case of learn packet, usualy only the first packet */
if (CGlobalInfo::is_learn_mode(CParserOption::LEARN_MODE_IP_OPTION)) {
diff --git a/src/dpdk/drivers/net/mlx5/mlx5_fdir.c b/src/dpdk/drivers/net/mlx5/mlx5_fdir.c
index 1515de01..c8340530 100644
--- a/src/dpdk/drivers/net/mlx5/mlx5_fdir.c
+++ b/src/dpdk/drivers/net/mlx5/mlx5_fdir.c
@@ -165,7 +165,7 @@ fdir_filter_to_flow_desc(const struct rte_eth_fdir_filter *fdir_filter,
rte_memcpy(desc->dst_ip,
fdir_filter->input.flow.ipv6_flow.dst_ip,
sizeof(desc->dst_ip));
- desc->tos = fdir_filter->input.flow.ipv6_flow.tc;
+ desc->tos = (uint8_t)fdir_filter->input.flow.ipv6_flow.hop_limits; /* TTL is map to TOS*/
desc->ip_id = (uint8_t)fdir_filter->input.flow.ipv6_flow.flow_label;
desc->proto = fdir_filter->input.flow.ipv6_flow.proto;
@@ -370,7 +370,7 @@ priv_fdir_flow_add(struct priv *priv,
spec_ipv6 = (struct ibv_exp_flow_spec_ipv6_ext *)spec_offset;
/* The second specification must be IP. */
- assert(spec_ipv6->type == IBV_EXP_FLOW_SPEC_IPV6);
+ assert(spec_ipv6->type == IBV_EXP_FLOW_SPEC_IPV6_EXT);
assert(spec_ipv6->size == sizeof(*spec_ipv6));
for (i = 0; i != RTE_DIM(desc->src_ip); ++i) {
@@ -386,6 +386,20 @@ priv_fdir_flow_add(struct priv *priv,
mask->ipv6_mask.dst_ip,
sizeof(spec_ipv6->mask.dst_ip));
+ spec_ipv6->val.next_hdr = desc->proto & mask->ipv6_mask.proto;
+ spec_ipv6->mask.next_hdr = mask->ipv6_mask.proto;
+
+ /* TOS */
+ if (desc->ip_id ==1 ){
+ spec_ipv6->mask.traffic_class = (0x1);
+ }else{
+ spec_ipv6->mask.traffic_class = 0x0;
+ }
+ spec_ipv6->val.traffic_class =
+ (desc->tos) & spec_ipv6->mask.traffic_class;// & mask->ipv4_mask.tos;
+
+ printf(" %x %x \n",spec_ipv6->val.traffic_class,spec_ipv6->mask.traffic_class);
+
/* Update priority */
attr->priority = 1;
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index de7221b5..3f07b8f8 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -6392,6 +6392,9 @@ void CTRexExtendedDriverBaseMlnx5G::update_configuration(port_cfg_t * cfg){
/* update mask */
cfg->m_port_conf.fdir_conf.mask.ipv4_mask.proto=0xff;
cfg->m_port_conf.fdir_conf.mask.ipv4_mask.tos=0x01;
+ cfg->m_port_conf.fdir_conf.mask.ipv6_mask.proto=0xff;
+ cfg->m_port_conf.fdir_conf.mask.ipv6_mask.tc=0x01;
+
}
void CTRexExtendedDriverBaseMlnx5G::add_del_rules(enum rte_filter_op op, uint8_t port_id, uint16_t type,
@@ -6502,36 +6505,23 @@ int CTRexExtendedDriverBaseMlnx5G::add_del_rx_flow_stat_rule(uint8_t port_id, en
int CTRexExtendedDriverBaseMlnx5G::configure_rx_filter_rules_statfull(CPhyEthIF * _if) {
uint32_t port_id = _if->get_port_id();
/* TTL==TOS */
-
+
/*PID=1 ==> MASK TOS=0x1/0x1*/
- //add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_UDP, 0x1, 1, 17, MAIN_DPDK_RX_Q, 0);
- //add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_TCP, 0x1, 1, 6, MAIN_DPDK_RX_Q, 0);
+ add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_UDP, 0x1, 1, 17, MAIN_DPDK_RX_Q, 0); /*TCP/UDP */
+ add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_TCP, 0x1, 1, 6, MAIN_DPDK_RX_Q, 0);
add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_OTHER, 0x1, 1, 132, MAIN_DPDK_RX_Q, 0); /*SCTP*/
add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_OTHER, 0x1, 1, 1, MAIN_DPDK_RX_Q, 0); /*ICMP*/
- return (0);
- /* Configure rules for latency measurement packets */
- //add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_UDP, TTL_RESERVE_DUPLICATE, 0, 0, MAIN_DPDK_RX_Q, 0);
- //add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_TCP, TTL_RESERVE_DUPLICATE, 0, 0, MAIN_DPDK_RX_Q, 0);
- /* MLX5-IPV6 support */
-
-// add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV6_UDP, ttl, tos, 0, MAIN_DPDK_RX_Q, 0);
-// add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV6_TCP, ttl, tos, 0, MAIN_DPDK_RX_Q, 0);
-
- //add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_OTHER, TTL_RESERVE_DUPLICATE , 0,0, MAIN_DPDK_RX_Q, 0);
- //add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_SCTP, TTL_RESERVE_DUPLICATE , 0,0, MAIN_DPDK_RX_Q, 0);
-
+ add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV6_UDP, 0x1, 1, 17, MAIN_DPDK_RX_Q, 0); /*TCP/UDP */
+ add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV6_TCP, 0x1, 1, 6, MAIN_DPDK_RX_Q, 0);
+ add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV6_OTHER, 0x1, 1, 132, MAIN_DPDK_RX_Q, 0); /*SCTP*/
+ add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV6_OTHER, 0x1, 1, 1, MAIN_DPDK_RX_Q, 0); /*ICMP*/
return 0;
}
int CTRexExtendedDriverBaseMlnx5G::configure_rx_filter_rules(CPhyEthIF * _if) {
if (get_is_stateless()) {
- //uint32_t port_id = _if->get_port_id();
- /*add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_TCP, 0, 0, FLOW_STAT_PAYLOAD_IP_ID, MAIN_DPDK_RX_Q, FDIR_PAYLOAD_RULES_HW_ID);
- add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_UDP, 0, 0, FLOW_STAT_PAYLOAD_IP_ID, MAIN_DPDK_RX_Q, FDIR_PAYLOAD_RULES_HW_ID);
- add_del_rules(RTE_ETH_FILTER_ADD, port_id, RTE_ETH_FLOW_NONFRAG_IPV4_OTHER, 0, 0, FLOW_STAT_PAYLOAD_IP_ID, MAIN_DPDK_RX_Q, FDIR_PAYLOAD_RULES_HW_ID);*/
- //rte_eth_fdir_stats_reset(_if->get_port_id(), NULL, FDIR_TEMP_HW_ID, 1);
- return 0; // Other rules are configured dynamically in stateless
+ return configure_rx_filter_rules_statfull(_if);
} else {
return configure_rx_filter_rules_statfull(_if);
}
diff --git a/src/pkt_gen.cpp b/src/pkt_gen.cpp
index eb9a26f9..45e3a298 100644
--- a/src/pkt_gen.cpp
+++ b/src/pkt_gen.cpp
@@ -30,7 +30,7 @@
#include <common/Network/Packet/Arp.h>
#include "rx_check_header.h"
#include "pkt_gen.h"
-
+#include "bp_sim.h"
// For use in tests
char *CTestPktGen::create_test_pkt(uint16_t l3_type, uint16_t l4_proto, uint8_t ttl, uint32_t ip_id, uint16_t flags
, uint16_t max_payload, int &pkt_size) {
@@ -52,7 +52,7 @@ char *CTestPktGen::create_test_pkt(uint16_t l3_type, uint16_t l4_proto, uint8_t
}
uint8_t ip_header[] = {
- 0x45,0x02,0x00,0x30,
+ 0x45,0x03,0x00,0x30,
0x00,0x00,0x40,0x00,
0xff,0x01,0xbd,0x04,
0x10,0x0,0x0,0x1, //SIP
@@ -60,7 +60,7 @@ char *CTestPktGen::create_test_pkt(uint16_t l3_type, uint16_t l4_proto, uint8_t
// 0x82, 0x0b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // IP option. change 45 to 48 (header len) if using it.
};
uint8_t ipv6_header[] = {
- 0x60,0x00,0xff,0x30, // traffic class + flow label
+ 0x60,0x10,0xff,0x30, // traffic class + flow label
0x00,0x00,0x40,0x00, // payload len + next header + hop limit
0x10,0x0,0x0,0x1,0x10,0x0,0x0,0x1,0x10,0x0,0x0,0x1,0x10,0x0,0x0,0x1, //SIP
0x30,0x0,0x0,0x1,0x10,0x0,0x0,0x1,0x30,0x0,0x0,0x1,0x10,0x0,0x0,0x1, //DIP
@@ -222,10 +222,22 @@ char *CTestPktGen::create_test_pkt(uint16_t l3_type, uint16_t l4_proto, uint8_t
switch(l3_type) {
case EthernetHeader::Protocol::IP:
ip->setTimeToLive(ttl);
+ if (ttl==TTL_RESERVE_DUPLICATE || ttl==(TTL_RESERVE_DUPLICATE-1)) {
+ ip->setTOS(TOS_TTL_RESERVE_DUPLICATE);
+ }else{
+ ip->setTOS(0x2);
+ }
+
ip->updateCheckSum();
break;
case EthernetHeader::Protocol::IPv6:
ipv6->setHopLimit(ttl);
+ if (ttl==TTL_RESERVE_DUPLICATE || ttl==(TTL_RESERVE_DUPLICATE-1)) {
+ ipv6->setTrafficClass(TOS_TTL_RESERVE_DUPLICATE);
+ }else{
+ ipv6->setTrafficClass(0x2);
+ }
+
break;
}