summaryrefslogtreecommitdiffstats
path: root/src/main_dpdk.h
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-02-08 11:25:07 +0200
committerIdo Barnea <ibarnea@cisco.com>2016-02-24 14:21:29 +0200
commitf0ab9eba97221e491cf7b3dd846eb8c23d920ec2 (patch)
treecaf0b2f4f9cc0874a53bb3af813d5bae8d644914 /src/main_dpdk.h
parent252b8ab3f41a18af8561cece71cf07bc9872f39f (diff)
Rx stat per flow. Low level working for xl710, and partly for i350.
added full clone (with CP VM) to stream
Diffstat (limited to 'src/main_dpdk.h')
-rw-r--r--src/main_dpdk.h91
1 files changed, 55 insertions, 36 deletions
diff --git a/src/main_dpdk.h b/src/main_dpdk.h
index e2c0cdb2..7357c0f4 100644
--- a/src/main_dpdk.h
+++ b/src/main_dpdk.h
@@ -1,27 +1,33 @@
/*
-Copyright (c) 2015-2016 Cisco Systems, Inc.
+ Copyright (c) 2015-2016 Cisco Systems, Inc.
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
#ifndef MAIN_DPDK_H
#define MAIN_DPDK_H
+#include <rte_ethdev.h>
#include "bp_sim.h"
+enum {
+ MAIN_DPDK_DATA_Q = 0,
+ MAIN_DPDK_RX_Q = 1,
+};
+
class CPhyEthIFStats {
-public:
+ public:
uint64_t ipackets; /**< Total number of successfully received packets. */
uint64_t ibytes; /**< Total number of successfully received bytes. */
uint64_t f_ipackets; /**< Total number of successfully received packets - filter SCTP*/
@@ -32,18 +38,22 @@ public:
uint64_t oerrors; /**< Total number of failed transmitted packets. */
uint64_t imcasts; /**< Total number of multicast received packets. */
uint64_t rx_nombuf; /**< Total number of RX mbuf allocation failures. */
-
-public:
+ uint64_t m_rx_per_flow [TREX_FDIR_STAT_SIZE]; // Per flow RX statistics
+ // Previous fdir stats values read from HW. Since on xl710 this is 32 bit, we save old value, to handle wrap around.
+ uint32_t m_fdir_prev_stats [TREX_FDIR_STAT_SIZE];
+ bool m_fdir_stats_first_time;
+ public:
void Clear();
void Dump(FILE *fd);
void DumpAll(FILE *fd);
};
class CPhyEthIF {
-public:
+ public:
CPhyEthIF (){
m_port_id=0;
m_rx_queue=0;
+ m_stats.m_fdir_stats_first_time = true;
}
bool Create(uint8_t portid){
m_port_id = portid;
@@ -59,18 +69,20 @@ public:
}
void configure(uint16_t nb_rx_queue,
- uint16_t nb_tx_queue,
- const struct rte_eth_conf *eth_conf);
+ uint16_t nb_tx_queue,
+ const struct rte_eth_conf *eth_conf);
void macaddr_get(struct ether_addr *mac_addr);
void get_stats(CPhyEthIFStats *stats);
+ int dump_fdir_global_stats(FILE *fd);
+ int get_rx_stats(uint64_t *stats, int index, bool reset);
void get_stats_1g(CPhyEthIFStats *stats);
void rx_queue_setup(uint16_t rx_queue_id,
- uint16_t nb_rx_desc,
+ uint16_t nb_rx_desc,
unsigned int socket_id,
const struct rte_eth_rxconf *rx_conf,
struct rte_mempool *mb_pool);
void tx_queue_setup(uint16_t tx_queue_id,
- uint16_t nb_tx_desc,
+ uint16_t nb_tx_desc,
unsigned int socket_id,
const struct rte_eth_txconf *tx_conf);
void configure_rx_drop_queue();
@@ -90,7 +102,7 @@ public:
void update_counters();
void stats_clear();
uint8_t get_port_id(){
- return (m_port_id);
+ return (m_port_id);
}
float get_last_tx_rate(){
return (m_last_tx_rate);
@@ -105,11 +117,11 @@ public:
return (m_last_rx_pps);
}
CPhyEthIFStats & get_stats(){
- return ( m_stats );
+ return ( m_stats );
}
void flush_rx_queue(void);
-
-public:
+ int add_rx_flow_stat_rule(uint8_t type, uint16_t proto, uint16_t id);
+ int del_rx_flow_stat_rule(uint8_t type, uint16_t proto, uint16_t id);
inline uint16_t tx_burst(uint16_t queue_id, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) {
return rte_eth_tx_burst(m_port_id, queue_id, tx_pkts, nb_pkts);
}
@@ -117,26 +129,27 @@ public:
return rte_eth_rx_burst(m_port_id, queue_id, rx_pkts, nb_pkts);
}
inline uint32_t pci_reg_read(uint32_t reg_off) {
- void *reg_addr;
- uint32_t reg_v;
- reg_addr = (void *)((char *)m_dev_info.pci_dev->mem_resource[0].addr +
- reg_off);
+ void *reg_addr;
+ uint32_t reg_v;
+ reg_addr = (void *)((char *)m_dev_info.pci_dev->mem_resource[0].addr +
+ reg_off);
reg_v = *((volatile uint32_t *)reg_addr);
return rte_le_to_cpu_32(reg_v);
}
- inline void pci_reg_write(uint32_t reg_off,
+ inline void pci_reg_write(uint32_t reg_off,
uint32_t reg_v) {
- void *reg_addr;
-
- reg_addr = (void *)((char *)m_dev_info.pci_dev->mem_resource[0].addr +
- reg_off);
- *((volatile uint32_t *)reg_addr) = rte_cpu_to_le_32(reg_v);
+ void *reg_addr;
+
+ reg_addr = (void *)((char *)m_dev_info.pci_dev->mem_resource[0].addr +
+ reg_off);
+ *((volatile uint32_t *)reg_addr) = rte_cpu_to_le_32(reg_v);
}
void dump_stats_extended(FILE *fd);
uint8_t get_rte_port_id(void) {
- return m_port_id;
+ return m_port_id;
}
-private:
+ int get_rx_stat_capabilities();
+ private:
uint8_t m_port_id;
uint8_t m_rx_queue;
struct rte_eth_link m_link;
@@ -151,8 +164,14 @@ private:
float m_last_rx_rate;
float m_last_tx_pps;
float m_last_rx_pps;
-public:
- struct rte_eth_dev_info m_dev_info;
+ public:
+ struct rte_eth_dev_info m_dev_info;
+};
+
+// Because it is difficult to move CGlobalTRex into this h file, defining interface class to it
+class CGlobalTRexInterface {
+ public:
+ CPhyEthIF *get_ports(uint8_t &port_num);
};
#endif