1IBV_CREATE_FLOW(3) Libibverbs Programmer's Manual IBV_CREATE_FLOW(3)
2
3
4
6 ibv_create_flow, ibv_destroy_flow - create or destroy flow steering
7 rules
8
10 #include <infiniband/verbs.h>
11
12 struct ibv_flow *ibv_create_flow(struct ibv_qp *qp,
13 struct ibv_flow_attr *flow_attr);
14 int ibv_destroy_flow(struct ibv_flow *flow_id);
15
16
18 ibv_create_flow()
19 allows a user application QP qp to be attached into a specified flow
20 flow which is defined in <infiniband/verbs.h>
21
22 struct ibv_flow_attr {
23 uint32_t comp_mask; /* Future extendibility */
24 enum ibv_flow_attr_type type; /* Rule type - see below */
25 uint16_t size; /* Size of command */
26 uint16_t priority; /* Rule priority - see below */
27 uint8_t num_of_specs; /* Number of ibv_flow_spec_xxx */
28 uint8_t port; /* The uplink port number */
29 uint32_t flags; /* Extra flags for rule - see below */
30 /* Following are the optional layers according to user request
31 * struct ibv_flow_spec_xxx
32 * struct ibv_flow_spec_yyy
33 */
34 };
35
36 enum ibv_flow_attr_type {
37 IBV_FLOW_ATTR_NORMAL = 0x0, /* Steering according to rule specifications */
38 IBV_FLOW_ATTR_ALL_DEFAULT = 0x1, /* Default unicast and multicast rule - receive all Eth traffic which isn't steered to any QP */
39 IBV_FLOW_ATTR_MC_DEFAULT = 0x2, /* Default multicast rule - receive all Eth multicast traffic which isn't steered to any QP */
40 IBV_FLOW_ATTR_SNIFFER = 0x3, /* Sniffer rule - receive all port traffic */
41 };
42
43 enum ibv_flow_flags {
44 IBV_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK = 1 << 0, /* Apply the rules on packets that were sent from the attached QP through loopback */
45 IBV_FLOW_ATTR_FLAGS_DONT_TRAP = 1 << 1, /* Rule doesn't trap received packets, allowing them to match lower prioritized rules */
46 };
47
48 enum ibv_flow_spec_type {
49 IBV_FLOW_SPEC_ETH = 0x20, /* Flow specification of L2 header */
50 IBV_FLOW_SPEC_IPV4 = 0x30, /* Flow specification of IPv4 header */
51 IBV_FLOW_SPEC_IPV6 = 0x31, /* Flow specification of IPv6 header */
52 IBV_FLOW_SPEC_IPV4_EXT = 0x32, /* Extended flow specification of IPv4 */
53 IBV_FLOW_SPEC_TCP = 0x40, /* Flow specification of TCP header */
54 IBV_FLOW_SPEC_UDP = 0x41, /* Flow specification of UDP header */
55 IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, /* Flow specification of VXLAN header */
56 IBV_FLOW_SPEC_INNER = 0x100, /* Flag making L2/L3/L4 specifications to be applied on the inner header */
57 IBV_FLOW_SPEC_ACTION_TAG = 0x1000, /* Action tagging matched packet */
58 IBV_FLOW_SPEC_ACTION_DROP = 0x1001, /* Action dropping matched packet */
59 };
60
61 Flow specification general structure:
62
63 struct ibv_flow_spec_xxx {
64 enum ibv_flow_spec_type type;
65 uint16_t size; /* Flow specification size = sizeof(struct ibv_flow_spec_xxx) */
66 struct ibv_flow_xxx_filter val;
67 struct ibv_flow_xxx_filter mask; /* Defines which bits from the filter value are applicable when looking for a match in the incoming packet */
68 };
69
70 Each spec struct holds the relevant network layer parameters for matching. To enforce the match, the user sets a mask for each parameter.
71 If the bit is set in the mask, the corresponding bit in the value should be matched.
72 Note that most vendors support either full mask (all "1"s) or zero mask (all "0"s).
73 Network parameters in the relevant network structs should be given in network order (big endian).
74
75
76 Flow domains and priority
77 Flow steering defines the concept of domain and priority. Each domain
78 represents an application that can attach a flow. Domains are priori‐
79 tized. A higher priority domain will always supersede a lower priority
80 domain when their flow specifications overlap.
81 IB verbs have the higher priority domain.
82 In addition to the domain, there is priority within each of the
83 domains. A lower priority numeric value (higher priority) takes prece‐
84 dence over matching rules with higher numeric priority value (lower
85 priority). It is important to note that the priority value of a flow
86 spec is used not only to establish the precedence of conflicting flow
87 matches but also as a way to abstract the order on which flow specs are
88 tested for matches. Flows with higher priorities will be tested before
89 flows with lower priorities.
90
91 ibv_destroy_flow()
92 destroys the flow flow_id.
93
95 ibv_create_flow() returns a pointer to the flow, or NULL if the request
96 fails. In case of an error, errno is updated.
97
98 ibv_destroy_flow() returns 0 on success, or the value of errno on fail‐
99 ure (which indicates the failure reason).
100
102 EINVAL
103 ibv_create_flow() flow specification, QP or priority are invalid
104
105 ibv_destroy_flow() flow_id is invalid
106
107 ENOMEM
108 Couldn't create/destroy flow, not enough memory
109
110 ENXIO
111 Device managed flow steering isn't currently supported
112
113 EPERM
114 No permissions to add the flow steering rule
115
117 1. These verbs are available only for devices supporting
118 IBV_DEVICE_MANAGED_FLOW_STEERING and only for QPs of Transport Ser‐
119 vice Type IBV_QPT_UD or IBV_QPT_RAW_PACKET
120 2. User must memset the spec struct with zeros before using it.
121 3. ether_type field in ibv_flow_eth_filter is the ethertype following
122 the last VLAN tag of the packet.
123 4. Only rule type IBV_FLOW_ATTR_NORMAL supports
124 IBV_FLOW_ATTR_FLAGS_DONT_TRAP flag.
125 5. No specifications are needed for IBV_FLOW_ATTR_SNIFFER rule type.
126
128 Below flow_attr defines a rule in priority 0 to match a destination mac
129 address and a source ipv4 address. For that, L2 and L3 specs are used.
130 If there is a hit on this rule, means the received packet has destina‐
131 tion mac: 66:11:22:33:44:55 and source ip: 0x0B86C806, the packet is
132 steered to its attached qp.
133
134 struct raw_eth_flow_attr {
135 struct ibv_flow_attr attr;
136 struct ibv_flow_spec_eth spec_eth;
137 struct ibv_flow_spec_ipv4 spec_ipv4;
138 } __attribute__((packed));
139
140 struct raw_eth_flow_attr flow_attr = {
141 .attr = {
142 .comp_mask = 0,
143 .type = IBV_FLOW_ATTR_NORMAL,
144 .size = sizeof(flow_attr),
145 .priority = 0,
146 .num_of_specs = 2,
147 .port = 1,
148 .flags = 0,
149 },
150 .spec_eth = {
151 .type = IBV_FLOW_SPEC_ETH,
152 .size = sizeof(struct ibv_flow_spec_eth),
153 .val = {
154 .dst_mac = {0x66, 0x11, 0x22, 0x33, 0x44, 0x55},
155 .src_mac = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
156 .ether_type = 0,
157 .vlan_tag = 0,
158 },
159 .mask = {
160 .dst_mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
161 .src_mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
162 .ether_type = 0,
163 .vlan_tag = 0,
164 }
165 },
166 .spec_ipv4 = {
167 .type = IBV_FLOW_SPEC_IPV4,
168 .size = sizeof(struct ibv_flow_spec_ipv4),
169 .val = {
170 .src_ip = 0x0B86C806,
171 .dst_ip = 0,
172 },
173 .mask = {
174 .src_ip = 0xFFFFFFFF,
175 .dst_ip = 0,
176 }
177 }
178 };
179
180
182 Hadar Hen Zion <hadarh@mellanox.com>
183
184 Matan Barak <matanb@mellanox.com>
185
186 Yishai Hadas <yishaih@mellanox.com>
187
188 Maor Gottlieb <maorg@mellanox.com>
189
190
191
192libibverbs 2016-03-15 IBV_CREATE_FLOW(3)