summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-04-14 13:06:04 +0300
committerIdo Barnea <ibarnea@cisco.com>2016-04-14 13:06:04 +0300
commite0720b15ec9dc695a8c1799e87cbe41a670cb616 (patch)
tree2d74a2195e6f8df326e90bf585990d019e9cc90b /src
parent4d311b49e0c283f5cd8b27d00482eb08bd18c201 (diff)
Support for flow stat for vlan packets on 82599 card using --vlan option
Diffstat (limited to 'src')
-rw-r--r--src/flow_stat_parser.cpp19
-rw-r--r--src/flow_stat_parser.h10
-rw-r--r--src/main_dpdk.cpp9
3 files changed, 32 insertions, 6 deletions
diff --git a/src/flow_stat_parser.cpp b/src/flow_stat_parser.cpp
index e83f8a51..59de7481 100644
--- a/src/flow_stat_parser.cpp
+++ b/src/flow_stat_parser.cpp
@@ -233,9 +233,28 @@ int C82599Parser::parse(uint8_t *p, uint16_t len) {
switch( ether->getNextProtocol() ) {
case EthernetHeader::Protocol::IP :
+ // In 82599 all streams should be with vlan, or without. Can't mix
+ if (m_vlan_supported)
+ return -1;
m_ipv4 = (IPHeader *)(p + ETH_HDR_LEN);
m_stat_supported = true;
break;
+ case EthernetHeader::Protocol::VLAN :
+ if (!m_vlan_supported)
+ return -1;
+ min_len += 4;
+ if (len < min_len)
+ return -1;
+ switch ( ether->getVlanProtocol() ){
+ case EthernetHeader::Protocol::IP:
+ m_ipv4 = (IPHeader *)(p + 18);
+ m_stat_supported = true;
+ break;
+ default:
+ m_stat_supported = false;
+ return -1;
+ }
+ break;
default:
m_stat_supported = false;
return -1;
diff --git a/src/flow_stat_parser.h b/src/flow_stat_parser.h
index 0c0655ee..b4f01900 100644
--- a/src/flow_stat_parser.h
+++ b/src/flow_stat_parser.h
@@ -27,10 +27,10 @@
class CFlowStatParser {
public:
- virtual ~CFlowStatParser() {};
+ virtual ~CFlowStatParser() {}
virtual void reset();
virtual int parse(uint8_t *pkt, uint16_t len);
- virtual bool is_stat_supported() {return m_stat_supported == true;};
+ virtual bool is_stat_supported() {return m_stat_supported == true;}
virtual int get_ip_id(uint16_t &ip_id);
virtual int set_ip_id(uint16_t ip_id);
virtual int get_l4_proto(uint8_t &proto);
@@ -45,8 +45,12 @@ class CFlowStatParser {
class C82599Parser : public CFlowStatParser {
public:
- ~C82599Parser() {};
+ C82599Parser(bool vlan_supported) {m_vlan_supported = vlan_supported;}
+ ~C82599Parser() {}
int parse(uint8_t *pkt, uint16_t len);
+
+ private:
+ bool m_vlan_supported;
};
#endif
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 65f8332e..bb9c3bac 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -1121,6 +1121,10 @@ public:
/* Note: divide by 2 to convert byte offset to word offset */
if (get_is_stateless()) {
m_port_conf.fdir_conf.flexbytes_offset = (14+4)/2;
+ /* Increment offset 4 bytes for the case where we add VLAN */
+ if ( CGlobalInfo::m_options.preview.get_vlan_mode_enable() ) {
+ m_port_conf.fdir_conf.flexbytes_offset += (4/2);
+ }
} else {
if ( CGlobalInfo::m_options.preview.get_ipv6_mode_enable() ) {
m_port_conf.fdir_conf.flexbytes_offset = (14+6)/2;
@@ -4974,7 +4978,7 @@ int CTRexExtendedDriverBase10G::wait_for_stable_link(){
}
CFlowStatParser *CTRexExtendedDriverBase10G::get_flow_stat_parser() {
- CFlowStatParser *parser = new C82599Parser();
+ CFlowStatParser *parser = new C82599Parser(CGlobalInfo::m_options.preview.get_vlan_mode_enable() ? true:false);
assert (parser);
return parser;
}
@@ -5488,6 +5492,5 @@ int TrexDpdkPlatformApi::get_active_pgids(flow_stat_active_t &result) const {
}
CFlowStatParser *TrexDpdkPlatformApi::get_flow_stat_parser() const {
- return CTRexExtendedDriverDb::Ins()->get_drv()
- ->get_flow_stat_parser();
+ return CTRexExtendedDriverDb::Ins()->get_drv()->get_flow_stat_parser();
}