aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Hurley <john.hurley@netronome.com>2017-12-19 11:58:29 -0500
committerDavid S. Miller <davem@davemloft.net>2017-12-19 14:52:13 -0500
commit3ca3059dc3a970f2a731632ee5851536dac6149c (patch)
tree9d1482da2ddc255b7e280e7c9d22a0e350ad13cb
parentbedeca15afd8f0a2d3ad3a76830b3f6525a2aeeb (diff)
nfp: flower: compile Geneve encap actions
Generate rules for the NFP to encapsulate packets in Geneve tunnels. Move the vxlan action code to generic udp tunnel actions and use core code for both vxlan and Geneve. Only support outputting to well known port 6081. Setting tunnel options is not supported yet. Only attempt to offload if the fw supports Geneve. Signed-off-by: John Hurley <john.hurley@netronome.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/action.c75
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/cmsg.h11
2 files changed, 48 insertions, 38 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c
index ca74c517f626..b3567a596fc1 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/action.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/action.c
@@ -81,6 +81,9 @@ static bool nfp_fl_netdev_is_tunnel_type(struct net_device *out_dev,
81 if (!strcmp(out_dev->rtnl_link_ops->kind, "vxlan")) 81 if (!strcmp(out_dev->rtnl_link_ops->kind, "vxlan"))
82 return tun_type == NFP_FL_TUNNEL_VXLAN; 82 return tun_type == NFP_FL_TUNNEL_VXLAN;
83 83
84 if (!strcmp(out_dev->rtnl_link_ops->kind, "geneve"))
85 return tun_type == NFP_FL_TUNNEL_GENEVE;
86
84 return false; 87 return false;
85} 88}
86 89
@@ -136,11 +139,23 @@ nfp_fl_output(struct nfp_fl_output *output, const struct tc_action *action,
136 return 0; 139 return 0;
137} 140}
138 141
139static bool nfp_fl_supported_tun_port(const struct tc_action *action) 142static enum nfp_flower_tun_type
143nfp_fl_get_tun_from_act_l4_port(struct nfp_app *app,
144 const struct tc_action *action)
140{ 145{
141 struct ip_tunnel_info *tun = tcf_tunnel_info(action); 146 struct ip_tunnel_info *tun = tcf_tunnel_info(action);
142 147 struct nfp_flower_priv *priv = app->priv;
143 return tun->key.tp_dst == htons(NFP_FL_VXLAN_PORT); 148
149 switch (tun->key.tp_dst) {
150 case htons(NFP_FL_VXLAN_PORT):
151 return NFP_FL_TUNNEL_VXLAN;
152 case htons(NFP_FL_GENEVE_PORT):
153 if (priv->flower_ext_feats & NFP_FL_FEATS_GENEVE)
154 return NFP_FL_TUNNEL_GENEVE;
155 /* FALLTHROUGH */
156 default:
157 return NFP_FL_TUNNEL_NONE;
158 }
144} 159}
145 160
146static struct nfp_fl_pre_tunnel *nfp_fl_pre_tunnel(char *act_data, int act_len) 161static struct nfp_fl_pre_tunnel *nfp_fl_pre_tunnel(char *act_data, int act_len)
@@ -165,38 +180,33 @@ static struct nfp_fl_pre_tunnel *nfp_fl_pre_tunnel(char *act_data, int act_len)
165} 180}
166 181
167static int 182static int
168nfp_fl_set_vxlan(struct nfp_fl_set_vxlan *set_vxlan, 183nfp_fl_set_ipv4_udp_tun(struct nfp_fl_set_ipv4_udp_tun *set_tun,
169 const struct tc_action *action, 184 const struct tc_action *action,
170 struct nfp_fl_pre_tunnel *pre_tun) 185 struct nfp_fl_pre_tunnel *pre_tun,
186 enum nfp_flower_tun_type tun_type)
171{ 187{
172 struct ip_tunnel_info *vxlan = tcf_tunnel_info(action); 188 size_t act_size = sizeof(struct nfp_fl_set_ipv4_udp_tun);
173 size_t act_size = sizeof(struct nfp_fl_set_vxlan); 189 struct ip_tunnel_info *ip_tun = tcf_tunnel_info(action);
174 u32 tmp_set_vxlan_type_index = 0; 190 u32 tmp_set_ip_tun_type_index = 0;
175 /* Currently support one pre-tunnel so index is always 0. */ 191 /* Currently support one pre-tunnel so index is always 0. */
176 int pretun_idx = 0; 192 int pretun_idx = 0;
177 193
178 if (vxlan->options_len) { 194 if (ip_tun->options_len)
179 /* Do not support options e.g. vxlan gpe. */
180 return -EOPNOTSUPP; 195 return -EOPNOTSUPP;
181 }
182 196
183 set_vxlan->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL; 197 set_tun->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL;
184 set_vxlan->head.len_lw = act_size >> NFP_FL_LW_SIZ; 198 set_tun->head.len_lw = act_size >> NFP_FL_LW_SIZ;
185 199
186 /* Set tunnel type and pre-tunnel index. */ 200 /* Set tunnel type and pre-tunnel index. */
187 tmp_set_vxlan_type_index |= 201 tmp_set_ip_tun_type_index |=
188 FIELD_PREP(NFP_FL_IPV4_TUNNEL_TYPE, NFP_FL_TUNNEL_VXLAN) | 202 FIELD_PREP(NFP_FL_IPV4_TUNNEL_TYPE, tun_type) |
189 FIELD_PREP(NFP_FL_IPV4_PRE_TUN_INDEX, pretun_idx); 203 FIELD_PREP(NFP_FL_IPV4_PRE_TUN_INDEX, pretun_idx);
190 204
191 set_vxlan->tun_type_index = cpu_to_be32(tmp_set_vxlan_type_index); 205 set_tun->tun_type_index = cpu_to_be32(tmp_set_ip_tun_type_index);
192 206 set_tun->tun_id = ip_tun->key.tun_id;
193 set_vxlan->tun_id = vxlan->key.tun_id;
194 set_vxlan->tun_flags = vxlan->key.tun_flags;
195 set_vxlan->ipv4_ttl = vxlan->key.ttl;
196 set_vxlan->ipv4_tos = vxlan->key.tos;
197 207
198 /* Complete pre_tunnel action. */ 208 /* Complete pre_tunnel action. */
199 pre_tun->ipv4_dst = vxlan->key.u.ipv4.dst; 209 pre_tun->ipv4_dst = ip_tun->key.u.ipv4.dst;
200 210
201 return 0; 211 return 0;
202} 212}
@@ -433,8 +443,8 @@ nfp_flower_loop_action(const struct tc_action *a,
433 struct net_device *netdev, 443 struct net_device *netdev,
434 enum nfp_flower_tun_type *tun_type, int *tun_out_cnt) 444 enum nfp_flower_tun_type *tun_type, int *tun_out_cnt)
435{ 445{
446 struct nfp_fl_set_ipv4_udp_tun *set_tun;
436 struct nfp_fl_pre_tunnel *pre_tun; 447 struct nfp_fl_pre_tunnel *pre_tun;
437 struct nfp_fl_set_vxlan *s_vxl;
438 struct nfp_fl_push_vlan *psh_v; 448 struct nfp_fl_push_vlan *psh_v;
439 struct nfp_fl_pop_vlan *pop_v; 449 struct nfp_fl_pop_vlan *pop_v;
440 struct nfp_fl_output *output; 450 struct nfp_fl_output *output;
@@ -482,26 +492,29 @@ nfp_flower_loop_action(const struct tc_action *a,
482 492
483 nfp_fl_push_vlan(psh_v, a); 493 nfp_fl_push_vlan(psh_v, a);
484 *a_len += sizeof(struct nfp_fl_push_vlan); 494 *a_len += sizeof(struct nfp_fl_push_vlan);
485 } else if (is_tcf_tunnel_set(a) && nfp_fl_supported_tun_port(a)) { 495 } else if (is_tcf_tunnel_set(a)) {
496 struct nfp_repr *repr = netdev_priv(netdev);
497 *tun_type = nfp_fl_get_tun_from_act_l4_port(repr->app, a);
498 if (*tun_type == NFP_FL_TUNNEL_NONE)
499 return -EOPNOTSUPP;
500
486 /* Pre-tunnel action is required for tunnel encap. 501 /* Pre-tunnel action is required for tunnel encap.
487 * This checks for next hop entries on NFP. 502 * This checks for next hop entries on NFP.
488 * If none, the packet falls back before applying other actions. 503 * If none, the packet falls back before applying other actions.
489 */ 504 */
490 if (*a_len + sizeof(struct nfp_fl_pre_tunnel) + 505 if (*a_len + sizeof(struct nfp_fl_pre_tunnel) +
491 sizeof(struct nfp_fl_set_vxlan) > NFP_FL_MAX_A_SIZ) 506 sizeof(struct nfp_fl_set_ipv4_udp_tun) > NFP_FL_MAX_A_SIZ)
492 return -EOPNOTSUPP; 507 return -EOPNOTSUPP;
493 508
494 *tun_type = NFP_FL_TUNNEL_VXLAN;
495 pre_tun = nfp_fl_pre_tunnel(nfp_fl->action_data, *a_len); 509 pre_tun = nfp_fl_pre_tunnel(nfp_fl->action_data, *a_len);
496 nfp_fl->meta.shortcut = cpu_to_be32(NFP_FL_SC_ACT_NULL); 510 nfp_fl->meta.shortcut = cpu_to_be32(NFP_FL_SC_ACT_NULL);
497 *a_len += sizeof(struct nfp_fl_pre_tunnel); 511 *a_len += sizeof(struct nfp_fl_pre_tunnel);
498 512
499 s_vxl = (struct nfp_fl_set_vxlan *)&nfp_fl->action_data[*a_len]; 513 set_tun = (void *)&nfp_fl->action_data[*a_len];
500 err = nfp_fl_set_vxlan(s_vxl, a, pre_tun); 514 err = nfp_fl_set_ipv4_udp_tun(set_tun, a, pre_tun, *tun_type);
501 if (err) 515 if (err)
502 return err; 516 return err;
503 517 *a_len += sizeof(struct nfp_fl_set_ipv4_udp_tun);
504 *a_len += sizeof(struct nfp_fl_set_vxlan);
505 } else if (is_tcf_tunnel_release(a)) { 518 } else if (is_tcf_tunnel_release(a)) {
506 /* Tunnel decap is handled by default so accept action. */ 519 /* Tunnel decap is handled by default so accept action. */
507 return 0; 520 return 0;
diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h
index 2e71c32690e9..992d2eec1019 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h
+++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h
@@ -173,16 +173,13 @@ struct nfp_fl_pre_tunnel {
173 __be32 extra[3]; 173 __be32 extra[3];
174}; 174};
175 175
176struct nfp_fl_set_vxlan { 176struct nfp_fl_set_ipv4_udp_tun {
177 struct nfp_fl_act_head head; 177 struct nfp_fl_act_head head;
178 __be16 reserved; 178 __be16 reserved;
179 __be64 tun_id; 179 __be64 tun_id __packed;
180 __be32 tun_type_index; 180 __be32 tun_type_index;
181 __be16 tun_flags; 181 __be32 extra[3];
182 u8 ipv4_ttl; 182};
183 u8 ipv4_tos;
184 __be32 extra[2];
185} __packed;
186 183
187/* Metadata with L2 (1W/4B) 184/* Metadata with L2 (1W/4B)
188 * ---------------------------------------------------------------- 185 * ----------------------------------------------------------------