1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2017 6WIND S.A. 3 * Copyright 2017 Mellanox Technologies, Ltd 4 */ 5 6 #ifndef _TAP_FLOW_H_ 7 #define _TAP_FLOW_H_ 8 9 #include <rte_flow.h> 10 #include <rte_flow_driver.h> 11 #include <rte_eth_tap.h> 12 #include <tap_autoconf.h> 13 14 /** 15 * In TC, priority 0 means we require the kernel to allocate one for us. 16 * In rte_flow, however, we want the priority 0 to be the most important one. 17 * Use an offset to have the most important priority being 1 in TC. 18 */ 19 #define PRIORITY_OFFSET 1 20 #define PRIORITY_MASK (0xfff) 21 #define MAX_PRIORITY (PRIORITY_MASK - PRIORITY_OFFSET) 22 #define GROUP_MASK (0xf) 23 #define GROUP_SHIFT 12 24 #define MAX_GROUP GROUP_MASK 25 #define RSS_PRIORITY_OFFSET RTE_PMD_TAP_MAX_QUEUES 26 27 /** 28 * These index are actually in reversed order: their priority is processed 29 * by subtracting their value to the lowest priority (PRIORITY_MASK). 30 * Thus the first one will have the lowest priority in the end 31 * (but biggest value). 32 */ 33 enum implicit_rule_index { 34 TAP_REMOTE_TX, 35 TAP_ISOLATE, 36 TAP_REMOTE_BROADCASTV6, 37 TAP_REMOTE_BROADCAST, 38 TAP_REMOTE_ALLMULTI, 39 TAP_REMOTE_PROMISC, 40 TAP_REMOTE_LOCAL_MAC, 41 TAP_REMOTE_MAX_IDX, 42 }; 43 44 enum bpf_fd_idx { 45 SEC_L3_L4, 46 SEC_MAX, 47 }; 48 49 int tap_dev_flow_ops_get(struct rte_eth_dev *dev, 50 const struct rte_flow_ops **ops); 51 int tap_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error); 52 53 int tap_flow_implicit_create(struct pmd_internals *pmd, 54 enum implicit_rule_index idx); 55 int tap_flow_implicit_destroy(struct pmd_internals *pmd, 56 enum implicit_rule_index idx); 57 int tap_flow_implicit_flush(struct pmd_internals *pmd, 58 struct rte_flow_error *error); 59 60 int tap_flow_bpf_cls_q(__u32 queue_idx); 61 int tap_flow_bpf_calc_l3_l4_hash(__u32 key_idx, int map_fd); 62 int tap_flow_bpf_rss_map_create(unsigned int key_size, unsigned int value_size, 63 unsigned int max_entries); 64 int tap_flow_bpf_update_rss_elem(int fd, void *key, void *value); 65 66 #endif /* _TAP_FLOW_H_ */ 67