aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qos_meter
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qos_meter')
-rw-r--r--examples/qos_meter/Makefile2
-rw-r--r--examples/qos_meter/main.c64
-rw-r--r--examples/qos_meter/main.h32
3 files changed, 74 insertions, 24 deletions
diff --git a/examples/qos_meter/Makefile b/examples/qos_meter/Makefile
index 69ac6617..46341b1a 100644
--- a/examples/qos_meter/Makefile
+++ b/examples/qos_meter/Makefile
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
$(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
diff --git a/examples/qos_meter/main.c b/examples/qos_meter/main.c
index f0f9bcaf..5cf4e9df 100644
--- a/examples/qos_meter/main.c
+++ b/examples/qos_meter/main.c
@@ -56,7 +56,6 @@ static struct rte_eth_conf port_conf = {
.mq_mode = ETH_MQ_RX_RSS,
.max_rx_pkt_len = ETHER_MAX_LEN,
.split_hdr_size = 0,
- .ignore_offload_bitfield = 1,
.offloads = (DEV_RX_OFFLOAD_CHECKSUM |
DEV_RX_OFFLOAD_CRC_STRIP),
},
@@ -90,14 +89,23 @@ static uint16_t port_tx;
static struct rte_mbuf *pkts_rx[PKT_RX_BURST_MAX];
struct rte_eth_dev_tx_buffer *tx_buffer;
-struct rte_meter_srtcm_params app_srtcm_params[] = {
- {.cir = 1000000 * 46, .cbs = 2048, .ebs = 2048},
+struct rte_meter_srtcm_params app_srtcm_params = {
+ .cir = 1000000 * 46,
+ .cbs = 2048,
+ .ebs = 2048
};
-struct rte_meter_trtcm_params app_trtcm_params[] = {
- {.cir = 1000000 * 46, .pir = 1500000 * 46, .cbs = 2048, .pbs = 2048},
+struct rte_meter_srtcm_profile app_srtcm_profile;
+
+struct rte_meter_trtcm_params app_trtcm_params = {
+ .cir = 1000000 * 46,
+ .pir = 1500000 * 46,
+ .cbs = 2048,
+ .pbs = 2048
};
+struct rte_meter_trtcm_profile app_trtcm_profile;
+
#define APP_FLOWS_MAX 256
FLOW_METER app_flows[APP_FLOWS_MAX];
@@ -105,12 +113,21 @@ FLOW_METER app_flows[APP_FLOWS_MAX];
static int
app_configure_flow_table(void)
{
- uint32_t i, j;
+ uint32_t i;
int ret;
- for (i = 0, j = 0; i < APP_FLOWS_MAX;
- i ++, j = (j + 1) % RTE_DIM(PARAMS)) {
- ret = FUNC_CONFIG(&app_flows[i], &PARAMS[j]);
+ ret = rte_meter_srtcm_profile_config(&app_srtcm_profile,
+ &app_srtcm_params);
+ if (ret)
+ return ret;
+
+ ret = rte_meter_trtcm_profile_config(&app_trtcm_profile,
+ &app_trtcm_params);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < APP_FLOWS_MAX; i++) {
+ ret = FUNC_CONFIG(&app_flows[i], &PROFILE);
if (ret)
return ret;
}
@@ -135,7 +152,10 @@ app_pkt_handle(struct rte_mbuf *pkt, uint64_t time)
enum policer_action action;
/* color input is not used for blind modes */
- output_color = (uint8_t) FUNC_METER(&app_flows[flow_id], time, pkt_len,
+ output_color = (uint8_t) FUNC_METER(&app_flows[flow_id],
+ &PROFILE,
+ time,
+ pkt_len,
(enum rte_meter_color) input_color);
/* Apply policing and set the output color */
@@ -312,6 +332,17 @@ main(int argc, char **argv)
rte_eth_dev_info_get(port_rx, &dev_info);
if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+ conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+ if (conf.rx_adv_conf.rss_conf.rss_hf !=
+ port_conf.rx_adv_conf.rss_conf.rss_hf) {
+ printf("Port %u modified RSS hash function based on hardware support,"
+ "requested:%#"PRIx64" configured:%#"PRIx64"\n",
+ port_rx,
+ port_conf.rx_adv_conf.rss_conf.rss_hf,
+ conf.rx_adv_conf.rss_conf.rss_hf);
+ }
+
ret = rte_eth_dev_configure(port_rx, 1, 1, &conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
@@ -330,7 +361,6 @@ main(int argc, char **argv)
rte_exit(EXIT_FAILURE, "Port %d RX queue setup error (%d)\n", port_rx, ret);
txq_conf = dev_info.default_txconf;
- txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
txq_conf.offloads = conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(port_rx, NIC_TX_QUEUE, nb_txd,
rte_eth_dev_socket_id(port_rx),
@@ -342,6 +372,17 @@ main(int argc, char **argv)
rte_eth_dev_info_get(port_tx, &dev_info);
if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+ conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+ if (conf.rx_adv_conf.rss_conf.rss_hf !=
+ port_conf.rx_adv_conf.rss_conf.rss_hf) {
+ printf("Port %u modified RSS hash function based on hardware support,"
+ "requested:%#"PRIx64" configured:%#"PRIx64"\n",
+ port_tx,
+ port_conf.rx_adv_conf.rss_conf.rss_hf,
+ conf.rx_adv_conf.rss_conf.rss_hf);
+ }
+
ret = rte_eth_dev_configure(port_tx, 1, 1, &conf);
if (ret < 0)
rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);
@@ -362,7 +403,6 @@ main(int argc, char **argv)
rte_exit(EXIT_FAILURE, "Port %d RX queue setup error (%d)\n", port_tx, ret);
txq_conf = dev_info.default_txconf;
- txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
txq_conf.offloads = conf.txmode.offloads;
ret = rte_eth_tx_queue_setup(port_tx, NIC_TX_QUEUE, nb_txd,
rte_eth_dev_socket_id(port_tx),
diff --git a/examples/qos_meter/main.h b/examples/qos_meter/main.h
index b27e8eb8..f51eb664 100644
--- a/examples/qos_meter/main.h
+++ b/examples/qos_meter/main.h
@@ -21,44 +21,52 @@ enum policer_action policer_table[e_RTE_METER_COLORS][e_RTE_METER_COLORS] =
#if APP_MODE == APP_MODE_FWD
-#define FUNC_METER(a,b,c,d) color, flow_id=flow_id, pkt_len=pkt_len, time=time
+#define FUNC_METER(m, p, time, pkt_len, pkt_color) \
+({ \
+ void *mp = m; \
+ void *pp = p; \
+ mp = mp; \
+ pp = pp; \
+ time = time; \
+ pkt_len = pkt_len; \
+ pkt_color; \
+})
#define FUNC_CONFIG(a, b) 0
-#define PARAMS app_srtcm_params
#define FLOW_METER int
+#define PROFILE app_srtcm_profile
#elif APP_MODE == APP_MODE_SRTCM_COLOR_BLIND
-#define FUNC_METER(a,b,c,d) rte_meter_srtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color) \
+ rte_meter_srtcm_color_blind_check(m, p, time, pkt_len)
#define FUNC_CONFIG rte_meter_srtcm_config
-#define PARAMS app_srtcm_params
#define FLOW_METER struct rte_meter_srtcm
+#define PROFILE app_srtcm_profile
#elif (APP_MODE == APP_MODE_SRTCM_COLOR_AWARE)
#define FUNC_METER rte_meter_srtcm_color_aware_check
#define FUNC_CONFIG rte_meter_srtcm_config
-#define PARAMS app_srtcm_params
#define FLOW_METER struct rte_meter_srtcm
+#define PROFILE app_srtcm_profile
#elif (APP_MODE == APP_MODE_TRTCM_COLOR_BLIND)
-#define FUNC_METER(a,b,c,d) rte_meter_trtcm_color_blind_check(a,b,c)
+#define FUNC_METER(m, p, time, pkt_len, pkt_color) \
+ rte_meter_trtcm_color_blind_check(m, p, time, pkt_len)
#define FUNC_CONFIG rte_meter_trtcm_config
-#define PARAMS app_trtcm_params
#define FLOW_METER struct rte_meter_trtcm
+#define PROFILE app_trtcm_profile
#elif (APP_MODE == APP_MODE_TRTCM_COLOR_AWARE)
-#define FUNC_METER rte_meter_trtcm_color_aware_check
+#define FUNC_METER rte_meter_trtcm_color_aware_check
#define FUNC_CONFIG rte_meter_trtcm_config
-#define PARAMS app_trtcm_params
#define FLOW_METER struct rte_meter_trtcm
+#define PROFILE app_trtcm_profile
#else
#error Invalid value for APP_MODE
#endif
-
-
-
#endif /* _MAIN_H_ */