| 1 |
.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md |
| 2 |
.TH IBV_CREATE_FLOW 3 2016-03-15 libibverbs "Libibverbs Programmer's Manual" |
| 3 |
.SH "NAME" |
| 4 |
ibv_create_flow, ibv_destroy_flow \- create or destroy flow steering rules |
| 5 |
.SH "SYNOPSIS" |
| 6 |
.nf |
| 7 |
.B #include <infiniband/verbs.h> |
| 8 |
.sp |
| 9 |
.BI "struct ibv_flow *ibv_create_flow(struct ibv_qp " "*qp" , |
| 10 |
.BI " struct ibv_flow_attr " "*flow_attr"); |
| 11 |
.BI "int ibv_destroy_flow(struct ibv_flow " "*flow_id"); |
| 12 |
.sp |
| 13 |
.fi |
| 14 |
.SH "DESCRIPTION" |
| 15 |
.SS ibv_create_flow() |
| 16 |
allows a user application QP |
| 17 |
.I qp |
| 18 |
to be attached into a specified flow |
| 19 |
.I flow |
| 20 |
which is defined in |
| 21 |
.I <infiniband/verbs.h> |
| 22 |
.PP |
| 23 |
.nf |
| 24 |
struct ibv_flow_attr { |
| 25 |
.in +8 |
| 26 |
uint32_t comp_mask; /* Future extendibility */ |
| 27 |
enum ibv_flow_attr_type type; /* Rule type - see below */ |
| 28 |
uint16_t size; /* Size of command */ |
| 29 |
uint16_t priority; /* Rule priority - see below */ |
| 30 |
uint8_t num_of_specs; /* Number of ibv_flow_spec_xxx */ |
| 31 |
uint8_t port; /* The uplink port number */ |
| 32 |
uint32_t flags; /* Extra flags for rule - see below */ |
| 33 |
/* Following are the optional layers according to user request |
| 34 |
* struct ibv_flow_spec_xxx |
| 35 |
* struct ibv_flow_spec_yyy |
| 36 |
*/ |
| 37 |
.in -8 |
| 38 |
}; |
| 39 |
.sp |
| 40 |
.nf |
| 41 |
enum ibv_flow_attr_type { |
| 42 |
.in +8 |
| 43 |
IBV_FLOW_ATTR_NORMAL = 0x0, /* Steering according to rule specifications */ |
| 44 |
IBV_FLOW_ATTR_ALL_DEFAULT = 0x1, /* Default unicast and multicast rule - receive all Eth traffic which isn't steered to any QP */ |
| 45 |
IBV_FLOW_ATTR_MC_DEFAULT = 0x2, /* Default multicast rule - receive all Eth multicast traffic which isn't steered to any QP */ |
| 46 |
IBV_FLOW_ATTR_SNIFFER = 0x3, /* Sniffer rule - receive all port traffic */ |
| 47 |
.in -8 |
| 48 |
}; |
| 49 |
.sp |
| 50 |
.nf |
| 51 |
enum ibv_flow_flags { |
| 52 |
.in +8 |
| 53 |
IBV_FLOW_ATTR_FLAGS_DONT_TRAP = 1 << 1, /* Rule doesn't trap received packets, allowing them to match lower prioritized rules */ |
| 54 |
IBV_FLOW_ATTR_FLAGS_EGRESS = 1 << 2, /* Match sent packets against EGRESS rules and carry associated actions if required */ |
| 55 |
.in -8 |
| 56 |
}; |
| 57 |
.fi |
| 58 |
.nf |
| 59 |
.br |
| 60 |
|
| 61 |
enum ibv_flow_spec_type { |
| 62 |
.in +8 |
| 63 |
IBV_FLOW_SPEC_ETH = 0x20, /* Flow specification of L2 header */ |
| 64 |
IBV_FLOW_SPEC_IPV4 = 0x30, /* Flow specification of IPv4 header */ |
| 65 |
IBV_FLOW_SPEC_IPV6 = 0x31, /* Flow specification of IPv6 header */ |
| 66 |
IBV_FLOW_SPEC_IPV4_EXT = 0x32, /* Extended flow specification of IPv4 */ |
| 67 |
IBV_FLOW_SPEC_ESP = 0x34, /* Flow specification of ESP (IPSec) header */ |
| 68 |
IBV_FLOW_SPEC_TCP = 0x40, /* Flow specification of TCP header */ |
| 69 |
IBV_FLOW_SPEC_UDP = 0x41, /* Flow specification of UDP header */ |
| 70 |
IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, /* Flow specification of VXLAN header */ |
| 71 |
IBV_FLOW_SPEC_GRE = 0x51, /* Flow specification of GRE header */ |
| 72 |
IBV_FLOW_SPEC_MPLS = 0x60, /* Flow specification of MPLS header */ |
| 73 |
IBV_FLOW_SPEC_INNER = 0x100, /* Flag making L2/L3/L4 specifications to be applied on the inner header */ |
| 74 |
IBV_FLOW_SPEC_ACTION_TAG = 0x1000, /* Action tagging matched packet */ |
| 75 |
IBV_FLOW_SPEC_ACTION_DROP = 0x1001, /* Action dropping matched packet */ |
| 76 |
IBV_FLOW_SPEC_ACTION_HANDLE = 0x1002, /* Carry out an action created by ibv_create_flow_action_xxxx verb */ |
| 77 |
IBV_FLOW_SPEC_ACTION_COUNT = 0x1003, /* Action count matched packet with a ibv_counters handle */ |
| 78 |
.in -8 |
| 79 |
}; |
| 80 |
.br |
| 81 |
|
| 82 |
Flow specification general structure: |
| 83 |
.BR |
| 84 |
struct ibv_flow_spec_xxx { |
| 85 |
.in +8 |
| 86 |
enum ibv_flow_spec_type type; |
| 87 |
uint16_t size; /* Flow specification size = sizeof(struct ibv_flow_spec_xxx) */ |
| 88 |
struct ibv_flow_xxx_filter val; |
| 89 |
struct ibv_flow_xxx_filter mask; /* Defines which bits from the filter value are applicable when looking for a match in the incoming packet */ |
| 90 |
.in -8 |
| 91 |
}; |
| 92 |
.PP |
| 93 |
Each spec struct holds the relevant network layer parameters for matching. To enforce the match, the user sets a mask for each parameter. |
| 94 |
.br |
| 95 |
Packets coming from the wire are matched against the flow specification. If a match is found, the associated flow actions are executed on the packet. |
| 96 |
.br |
| 97 |
In ingress flows, the QP parameter is treated as another action of scattering the packet to the respected QP. |
| 98 |
.br |
| 99 |
If the bit is set in the mask, the corresponding bit in the value should be matched. |
| 100 |
.br |
| 101 |
Note that most vendors support either full mask (all "1"s) or zero mask (all "0"s). |
| 102 |
.br |
| 103 |
.B Network parameters in the relevant network structs should be given in network order (big endian). |
| 104 |
|
| 105 |
.SS Flow domains and priority |
| 106 |
Flow steering defines the concept of domain and priority. Each domain represents an application that can attach a flow. |
| 107 |
Domains are prioritized. A higher priority domain will always supersede a lower priority domain when their flow specifications overlap. |
| 108 |
.br |
| 109 |
.B IB verbs have the higher priority domain. |
| 110 |
.br |
| 111 |
In addition to the domain, there is priority within each of the domains. |
| 112 |
A lower priority numeric value (higher priority) takes precedence over matching rules with higher numeric priority value (lower priority). |
| 113 |
It is important to note that the priority value of a flow spec is used not only to establish the precedence of conflicting flow matches |
| 114 |
but also as a way to abstract the order on which flow specs are tested for matches. Flows with higher priorities will be tested before flows with lower priorities. |
| 115 |
|
| 116 |
.SS Rules definition ordering |
| 117 |
An application can provide the ibv_flow_spec_xxx rules in an un-ordered scheme. In this case, each spec should be well |
| 118 |
defined and match a specific network header layer. |
| 119 |
In some cases, when certain flow spec types are present in the spec list, it is required to provide the list in an |
| 120 |
ordered manner so that the position of that flow spec type in the protocol stack is strictly defined. |
| 121 |
When the certain spec type, which requires the ordering, resides in the inner network protocol stack (in tunnel |
| 122 |
protocols) the ordering should be applied to the inner network specs and should be combined with the inner spec indication using |
| 123 |
the IBV_FLOW_SPEC_INNER flag. |
| 124 |
For example: An MPLS spec which attempts to match an MPLS tag in the inner network should have the |
| 125 |
IBV_FLOW_SPEC_INNER flag set and so do the rest of the inner network specs. On top of that, all the inner network specs should be provided in |
| 126 |
an ordered manner. |
| 127 |
This is essential to represent many of the encapsulation tunnel protocols. |
| 128 |
.br |
| 129 |
|
| 130 |
The flow spec types which require this sort of ordering are: |
| 131 |
.br |
| 132 |
.B 1. IBV_FLOW_SPEC_MPLS - |
| 133 |
.br |
| 134 |
Since MPLS header can appear at several locations in the protocol stack and can also be |
| 135 |
encapsulated on top of different layers, it is required to place this spec according to its exact location in the |
| 136 |
protocol stack. |
| 137 |
.br |
| 138 |
.SS ibv_destroy_flow() |
| 139 |
destroys the flow |
| 140 |
.I flow_id\fR. |
| 141 |
.SH "RETURN VALUE" |
| 142 |
.B ibv_create_flow() |
| 143 |
returns a pointer to the flow, or NULL if the request fails. In case of an error, errno is updated. |
| 144 |
.PP |
| 145 |
.B ibv_destroy_flow() |
| 146 |
returns 0 on success, or the value of errno on failure (which indicates the failure reason). |
| 147 |
.SH "ERRORS" |
| 148 |
.SS EINVAL |
| 149 |
.B ibv_create_flow() |
| 150 |
flow specification, QP or priority are invalid |
| 151 |
.PP |
| 152 |
.B ibv_destroy_flow() |
| 153 |
flow_id is invalid |
| 154 |
.SS ENOMEM |
| 155 |
Couldn't create/destroy flow, not enough memory |
| 156 |
.SS ENXIO |
| 157 |
Device managed flow steering isn't currently supported |
| 158 |
.SS EPERM |
| 159 |
No permissions to add the flow steering rule |
| 160 |
.SH "NOTES" |
| 161 |
1. These verbs are available only for devices supporting |
| 162 |
.br |
| 163 |
IBV_DEVICE_MANAGED_FLOW_STEERING and only for QPs of Transport Service Type |
| 164 |
.BR IBV_QPT_UD |
| 165 |
or |
| 166 |
.BR IBV_QPT_RAW_PACKET |
| 167 |
.br |
| 168 |
2. User must memset the spec struct with zeros before using it. |
| 169 |
.br |
| 170 |
3. ether_type field in ibv_flow_eth_filter is the ethertype following the last VLAN tag of the packet. |
| 171 |
.br |
| 172 |
4. Only rule type IBV_FLOW_ATTR_NORMAL supports IBV_FLOW_ATTR_FLAGS_DONT_TRAP flag. |
| 173 |
.br |
| 174 |
5. No specifications are needed for IBV_FLOW_ATTR_SNIFFER rule type. |
| 175 |
.br |
| 176 |
6. When IBV_FLOW_ATTR_FLAGS_EGRESS flag is set, the qp parameter is used only as a mean to get the device. |
| 177 |
.br |
| 178 |
.PP |
| 179 |
.SH EXAMPLE |
| 180 |
.br |
| 181 |
Below flow_attr defines a rule in priority 0 to match a destination |
| 182 |
mac address and a source ipv4 address. For that, L2 and L3 specs are used. |
| 183 |
.br |
| 184 |
If there is a hit on this rule, means the |
| 185 |
received packet has destination mac: 66:11:22:33:44:55 and source ip: 0x0B86C806, |
| 186 |
the packet is steered to its attached qp. |
| 187 |
.sp |
| 188 |
.nf |
| 189 |
struct raw_eth_flow_attr { |
| 190 |
.in +8 |
| 191 |
struct ibv_flow_attr attr; |
| 192 |
struct ibv_flow_spec_eth spec_eth; |
| 193 |
struct ibv_flow_spec_ipv4 spec_ipv4; |
| 194 |
.in -8 |
| 195 |
} __attribute__((packed)); |
| 196 |
.sp |
| 197 |
.nf |
| 198 |
struct raw_eth_flow_attr flow_attr = { |
| 199 |
.in +8 |
| 200 |
.attr = { |
| 201 |
.comp_mask = 0, |
| 202 |
.type = IBV_FLOW_ATTR_NORMAL, |
| 203 |
.size = sizeof(flow_attr), |
| 204 |
.priority = 0, |
| 205 |
.num_of_specs = 2, |
| 206 |
.port = 1, |
| 207 |
.flags = 0, |
| 208 |
}, |
| 209 |
.spec_eth = { |
| 210 |
.type = IBV_FLOW_SPEC_ETH, |
| 211 |
.size = sizeof(struct ibv_flow_spec_eth), |
| 212 |
.val = { |
| 213 |
.dst_mac = {0x66, 0x11, 0x22, 0x33, 0x44, 0x55}, |
| 214 |
.src_mac = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, |
| 215 |
.ether_type = 0, |
| 216 |
.vlan_tag = 0, |
| 217 |
}, |
| 218 |
.mask = { |
| 219 |
.dst_mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, |
| 220 |
.src_mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, |
| 221 |
.ether_type = 0, |
| 222 |
.vlan_tag = 0, |
| 223 |
} |
| 224 |
}, |
| 225 |
.spec_ipv4 = { |
| 226 |
.type = IBV_FLOW_SPEC_IPV4, |
| 227 |
.size = sizeof(struct ibv_flow_spec_ipv4), |
| 228 |
.val = { |
| 229 |
.src_ip = 0x0B86C806, |
| 230 |
.dst_ip = 0, |
| 231 |
}, |
| 232 |
.mask = { |
| 233 |
.src_ip = 0xFFFFFFFF, |
| 234 |
.dst_ip = 0, |
| 235 |
} |
| 236 |
} |
| 237 |
.in -8 |
| 238 |
}; |
| 239 |
.sp |
| 240 |
.nf |
| 241 |
.SH "AUTHORS" |
| 242 |
.TP |
| 243 |
Hadar Hen Zion <[email protected]> |
| 244 |
.TP |
| 245 |
Matan Barak <[email protected]> |
| 246 |
.TP |
| 247 |
Yishai Hadas <[email protected]> |
| 248 |
.TP |
| 249 |
Maor Gottlieb <[email protected]> |