support for tunnel in ice eswitch
Subsystems (2)
Tony Nguyen
maintainerv2 cover support for tunnel in ice eswitch
This series adds the support for ice VXLAN, Geneve and GRE offload.
Support adding drop and redirect filter from and to this tunnel devices. From means from uplink to VF and to means from VF to uplink. There is no support for decapsulation and encapsulation offload.
example:
- VXLAN from uplink to VF:
tc filter add dev $VXLAN_DEV protocol ip parent ffff: flower enc_dst_ip \
$VF1_IP enc_key_id $VXLAN_VNI action mirred egress redirect dev $VF1_PR
- VXLAN from VF to uplink:
tc filter add dev $VF1_PR protocol ip parent ffff: flower enc_dst_ip \
$LP_IP enc_key_id $VXLAN_VNI action mirred egress redirect dev $VXLAN_DEV
---
v2:
- Fix sparse error and kdoc issues
- Fix abbreviations
Michal Swiatkowski (4):
ice: support for indirect notification
ice: VXLAN and Geneve TC support
ice: low level support for tunnels
ice: support for GRE in eswitch
drivers/net/ethernet/intel/ice/ice.h | 8 + .../net/ethernet/intel/ice/ice_flex_pipe.c | 30 +- .../net/ethernet/intel/ice/ice_flex_type.h | 4 + drivers/net/ethernet/intel/ice/ice_main.c | 196 ++++++++- .../ethernet/intel/ice/ice_protocol_type.h | 35 ++ drivers/net/ethernet/intel/ice/ice_switch.c | 375 ++++++++++++++++- drivers/net/ethernet/intel/ice/ice_switch.h | 3 + drivers/net/ethernet/intel/ice/ice_tc_lib.c | 392 ++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 10 + 9 files changed, 1004 insertions(+), 49 deletions(-)
Signature · 1 line
2.31.1
Tony Nguyen
maintainerPATCH v2 1/4 ice: support for indirect notification
From: Michal Swiatkowski <[email protected]>
Implement indirect notification mechanism to support offloading TC rules on tunnel devices.
Keep indirect block list in netdev priv. Notification will call setting tc cls flower function.
--- drivers/net/ethernet/intel/ice/ice.h | 8 + drivers/net/ethernet/intel/ice/ice_main.c | 198 +++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 6 + 3 files changed, 210 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +8 -0
@@ -34,6 +34,7 @@#include <linux/if_bridge.h> #include <linux/ctype.h> #include <linux/bpf.h> +#include <linux/btf.h> #include <linux/auxiliary_bus.h> #include <linux/avf/virtchnl.h> #include <linux/cpu_rmap.h>
@@ -544,6 +545,13 @@ struct ice_pf {struct ice_netdev_priv {struct ice_vsi *vsi;struct ice_repr *repr; +/* indirect block callbacks on registered higher level devices +* (e.g. tunnel devices) +* +* tc_indr_block_cb_priv_list is used to lookup indirect callback +* private data +*/ +struct list_head tc_indr_block_priv_list; };/**
drivers/net/ethernet/intel/ice/ice_main.c +196 -2
247 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_tc_lib.h +6 -0
@@ -23,6 +23,12 @@#define ICE_TC_FLWR_FIELD_ENC_DST_MAC BIT(16)#define ICE_TC_FLWR_FIELD_ETH_TYPE_ID BIT(17) +struct ice_indr_block_priv { +struct net_device *netdev; +struct ice_netdev_priv *np; +struct list_head list; +}; +struct ice_tc_flower_action {u32 tc_class;enum ice_sw_fwd_act_type fltr_act;
Signature · 1 line
2.31.1
PATCH v2 1/4 ice: support for indirect notification
Dear Michal, dear Tony,
Am 12.10.21 um 20:31 schrieb Tony Nguyen:
Quoted 7 lines
From: Michal Swiatkowski <[email protected]>
Implement indirect notification mechanism to support offloading TC rules on tunnel devices.
Keep indirect block list in netdev priv. Notification will call setting tc cls flower function.
With what hardware was this tested?
Quoted 20 lines
Signed-off-by Michal Swiatkowski <[email protected]>--- drivers/net/ethernet/intel/ice/ice.h | 8 + drivers/net/ethernet/intel/ice/ice_main.c | 198 +++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 6 + 3 files changed, 210 insertions(+), 2 deletions(-)drivers/net/ethernet/intel/ice/ice.h +1
-0@@ -34,6 +34,7 @@#include <linux/if_bridge.h> #include <linux/ctype.h> #include <linux/bpf.h> +#include <linux/btf.h> #include <linux/auxiliary_bus.h> #include <linux/avf/virtchnl.h> #include <linux/cpu_rmap.h>
drivers/net/ethernet/intel/ice/ice.h struct ice_pf { · line 551
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice.h +4
-0@@ -544,6 +545,13 @@ struct ice_pf {struct ice_netdev_priv {struct ice_vsi *vsi;struct ice_repr *repr; +/* indirect block callbacks on registered higher level devices +* (e.g. tunnel devices) +* +* tc_indr_block_cb_priv_list is used to lookup indirect callback
Nit: look up
Quoted 184 lines
drivers/net/ethernet/intel/ice/ice.h +3
-0+* private data +*/ +struct list_head tc_indr_block_priv_list; };/** drivers/net/ethernet/intel/ice/ice_main.c +118
-2@@ -55,6 +55,12 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type);static void ice_vsi_release_all (struct ice_pf *pf); +static int +ice_indr_setup_tc_cb (struct net_device *netdev,struct Qdisc *sch, +void *cb_priv,enum tc_setup_type type,void *type_data, +void *data, +void (*cleanup)(struct flow_block_cb *block_cb)); +bool netif_is_ice (struct net_device *dev) {return dev && (dev->netdev_ops == &ice_netdev_ops);@@ -3399,6 +3405,63 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,return ret; } +/** +* ice_rep_indr_tc_block_unbind +* @cb_priv: indirection block private data +*/ +static void ice_rep_indr_tc_block_unbind (void *cb_priv) +{ +struct ice_indr_block_priv *indr_priv = cb_priv; + +list_del (&indr_priv->list); +kfree (indr_priv); +} + +/** +* ice_tc_indir_block_unregister - Unregister TC indirect block notifications +* @vsi: VSI struct which has the netdev +*/ +static void ice_tc_indir_block_unregister (struct ice_vsi *vsi) +{ +struct ice_netdev_priv *np =netdev_priv (vsi->netdev); + +flow_indr_dev_unregister (ice_indr_setup_tc_cb, np, + ice_rep_indr_tc_block_unbind); +} + +/** +* ice_tc_indir_block_remove - clean indirect TC block notifications +* @pf: PF structure +*/ +static void ice_tc_indir_block_remove (struct ice_pf *pf) +{ +struct ice_vsi *pf_vsi =ice_get_main_vsi (pf); + +if (!pf_vsi) +return ; + +ice_tc_indir_block_unregister (pf_vsi); +} + +/** +* ice_tc_indir_block_register - Register TC indirect block notifications +* @vsi: VSI struct which has the netdev +* +* Returns 0 on success, negative value on failure +*/ +static int ice_tc_indir_block_register (struct ice_vsi *vsi) +{ +struct ice_netdev_priv *np; + +if (!vsi || !vsi->netdev) +return -EINVAL ; + + np =netdev_priv (vsi->netdev); + +INIT_LIST_HEAD (&np->tc_indr_block_priv_list); +return flow_indr_dev_register (ice_indr_setup_tc_cb, np); +} +/** * ice_setup_pf_sw - Setup the HW switch on startup or after reset * @pf: board private structure @@ -3407,6 +3470,7 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,*/ static int ice_setup_pf_sw (struct ice_pf *pf) { +struct device *dev =ice_pf_to_dev (pf);struct ice_vsi *vsi;int status =0 ;@@ -3425,6 +3489,13 @@ static int ice_setup_pf_sw(struct ice_pf *pf)/* netdev has to be configured before setting frame size */ ice_vsi_cfg_frame_size (vsi); +/* init indirect block notifications */ + status =ice_tc_indir_block_register (vsi); +if (status) { +dev_err (dev,"Failed to register netdev notifier\n" ); + goto unroll_cfg_netdev; + } +/* Setup DCB netlink interface */ ice_dcbnl_setup (vsi);@@ -3436,7 +3507,7 @@ static int ice_setup_pf_sw(struct ice_pf *pf) status =ice_set_cpu_rx_rmap (vsi);if (status) { -dev_err (ice_pf_to_dev (pf),"Failed to set CPU Rx map VSI %d error %d\n" , +dev_err (dev,"Failed to set CPU Rx map VSI %d error %d\n" , vsi->vsi_num, status); status = -EINVAL ; goto unroll_napi_add;@@ -3449,8 +3520,9 @@ static int ice_setup_pf_sw(struct ice_pf *pf) free_cpu_rx_map:ice_free_cpu_rx_rmap (vsi); - unroll_napi_add: +ice_tc_indir_block_unregister (vsi); +unroll_cfg_netdev:if (vsi) {ice_napi_del (vsi);if (vsi->netdev) {@@ -4727,6 +4799,8 @@ static void ice_remove(struct pci_dev *pdev)msleep (100 ); } +ice_tc_indir_block_remove (pf); +if (test_bit (ICE_FLAG_SRIOV_ENA , pf->flags)) {set_bit (ICE_VF_RESETS_DISABLED , pf->state);ice_free_vfs (pf);@@ -7272,6 +7346,126 @@ ice_setup_tc(struct net_device *netdev, enum tc_setup_type type,return -EOPNOTSUPP ; } +static struct ice_indr_block_priv * +ice_indr_block_priv_lookup (struct ice_netdev_priv *np, +struct net_device *netdev) +{ +struct ice_indr_block_priv *cb_priv; + +/* All callback list access should be protected by RTNL. */ +ASSERT_RTNL (); + +list_for_each_entry (cb_priv, &np->tc_indr_block_priv_list, list) { +if (!cb_priv->netdev) +return NULL ; +if (cb_priv->netdev == netdev) +return cb_priv; + } +return NULL ; +} + +static int +ice_indr_setup_block_cb (enum tc_setup_type type,void *type_data, +void *indr_priv) +{ +struct ice_indr_block_priv *priv = indr_priv; +struct ice_netdev_priv *np = priv->np; + +switch (type) { +case TC_SETUP_CLSFLOWER : +return ice_setup_tc_cls_flower (np, priv->netdev, + (struct flow_cls_offload *) + type_data); +default : +return -EOPNOTSUPP ; + } +} + +static int +ice_indr_setup_tc_block (struct net_device *netdev,struct Qdisc *sch, +struct ice_netdev_priv *np, +struct flow_block_offload *f,void *data, +void (*cleanup)(struct flow_block_cb *block_cb)) +{ +struct ice_indr_block_priv *indr_priv;
drivers/net/ethernet/intel/ice/ice_main.c ice_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 7400
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_main.c +10
-0+struct flow_block_cb *block_cb; + +int tunnel_type =0 ; + +if (tunnel_type !=TNL_VXLAN && tunnel_type !=TNL_GENEVE && + !(is_vlan_dev (netdev) && +vlan_dev_real_dev (netdev) == np->vsi->netdev)) +return -EOPNOTSUPP ; + +if (f->binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS )
Could you please document in the commit message, why other types are not supported?
Quoted 79 lines
drivers/net/ethernet/intel/ice/ice_main.c +68
-0+return -EOPNOTSUPP ; + +switch (f->command) { +case FLOW_BLOCK_BIND : + indr_priv =ice_indr_block_priv_lookup (np, netdev); +if (indr_priv) +return -EEXIST ; + + indr_priv =kzalloc (sizeof (*indr_priv),GFP_KERNEL ); +if (!indr_priv) +return -ENOMEM ; + + indr_priv->netdev = netdev; + indr_priv->np = np; +list_add (&indr_priv->list, &np->tc_indr_block_priv_list); + + block_cb = +flow_indr_block_cb_alloc (ice_indr_setup_block_cb, + indr_priv, indr_priv, + ice_rep_indr_tc_block_unbind, + f, netdev, sch, data, np, + cleanup); + +if (IS_ERR (block_cb)) { +list_del (&indr_priv->list); +kfree (indr_priv); +return PTR_ERR (block_cb); + } +flow_block_cb_add (block_cb, f); +list_add_tail (&block_cb->driver_list, &ice_block_cb_list); +return 0 ; +case FLOW_BLOCK_UNBIND : + indr_priv =ice_indr_block_priv_lookup (np, netdev); +if (!indr_priv) +return -ENOENT ; + + block_cb =flow_block_cb_lookup (f->block, + ice_indr_setup_block_cb, + indr_priv); +if (!block_cb) +return -ENOENT ; + +flow_indr_block_cb_remove (block_cb, f); + +list_del (&block_cb->driver_list); +return 0 ; +default : +return -EOPNOTSUPP ; + } +return 0 ; +} + +static int +ice_indr_setup_tc_cb (struct net_device *netdev,struct Qdisc *sch, +void *cb_priv,enum tc_setup_type type,void *type_data, +void *data, +void (*cleanup)(struct flow_block_cb *block_cb)) +{ +switch (type) { +case TC_SETUP_BLOCK : +return ice_indr_setup_tc_block (netdev, sch, cb_priv, type_data, + data, cleanup); + +default : +return -EOPNOTSUPP ; + } +} +/** * ice_open - Called when a network interface becomes active * @netdev: network interface device structure drivers/net/ethernet/intel/ice/ice_tc_lib.h +0
-0@@ -23,6 +23,12 @@#define ICE_TC_FLWR_FIELD_ENC_DST_MAC BIT(16)#define ICE_TC_FLWR_FIELD_ETH_TYPE_ID BIT(17)
drivers/net/ethernet/intel/ice/ice_tc_lib.h line 34
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_tc_lib.h +6
-0+struct ice_indr_block_priv { +struct net_device *netdev; +struct ice_netdev_priv *np; +struct list_head list; +}; +struct ice_tc_flower_action {u32 tc_class;enum ice_sw_fwd_act_type fltr_act;
Kind regards,
Paul
PATCH v2 1/4 ice: support for indirect notification
Quoted 6 lines · Paul Menzel
Dear Michal, dear Tony,
Am 12.10.21 um 20:31 schrieb Tony Nguyen:
Quoted 2 lines
From: Michal Swiatkowski <[email protected]>
Quoted 8 lines
Quoted 5 lines
Implement indirect notification mechanism to support offloading TC rules on tunnel devices.
Keep indirect block list in netdev priv. Notification will call setting tc cls flower function.
With what hardware was this tested?
This was tested on cvl card (E810-C).
Quoted 208 lines
Quoted 20 lines
Signed-off-by Michal Swiatkowski <[email protected]>--- drivers/net/ethernet/intel/ice/ice.h | 8 + drivers/net/ethernet/intel/ice/ice_main.c | 198 +++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 6 + 3 files changed, 210 insertions(+), 2 deletions(-)drivers/net/ethernet/intel/ice/ice.h +1
-0@@ -34,6 +34,7 @@#include <linux/if_bridge.h> #include <linux/ctype.h> #include <linux/bpf.h> +#include <linux/btf.h> #include <linux/auxiliary_bus.h> #include <linux/avf/virtchnl.h> #include <linux/cpu_rmap.h> drivers/net/ethernet/intel/ice/ice.h struct ice_pf { · line 551
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice.h +4
-0@@ -544,6 +545,13 @@ struct ice_pf {struct ice_netdev_priv {struct ice_vsi *vsi;struct ice_repr *repr; +/* indirect block callbacks on registered higher level devices +* (e.g. tunnel devices) +* +* tc_indr_block_cb_priv_list is used to lookup indirect callback Nit: look up
Quoted 178 lines
drivers/net/ethernet/intel/ice/ice.h +3
-0+* private data +*/ +struct list_head tc_indr_block_priv_list; };/** drivers/net/ethernet/intel/ice/ice_main.c +123
-2@@ -55,6 +55,12 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type);static void ice_vsi_release_all (struct ice_pf *pf); +static int +ice_indr_setup_tc_cb (struct net_device *netdev,struct Qdisc *sch, +void *cb_priv,enum tc_setup_type type,void *type_data, +void *data, +void (*cleanup)(struct flow_block_cb *block_cb)); +bool netif_is_ice (struct net_device *dev) {return dev && (dev->netdev_ops == &ice_netdev_ops);@@ -3399,6 +3405,63 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,return ret; } +/** +* ice_rep_indr_tc_block_unbind +* @cb_priv: indirection block private data +*/ +static void ice_rep_indr_tc_block_unbind (void *cb_priv) +{ +struct ice_indr_block_priv *indr_priv = cb_priv; + +list_del (&indr_priv->list); +kfree (indr_priv); +} + +/** +* ice_tc_indir_block_unregister - Unregister TC indirect block notifications +* @vsi: VSI struct which has the netdev +*/ +static void ice_tc_indir_block_unregister (struct ice_vsi *vsi) +{ +struct ice_netdev_priv *np =netdev_priv (vsi->netdev); + +flow_indr_dev_unregister (ice_indr_setup_tc_cb, np, + ice_rep_indr_tc_block_unbind); +} + +/** +* ice_tc_indir_block_remove - clean indirect TC block notifications +* @pf: PF structure +*/ +static void ice_tc_indir_block_remove (struct ice_pf *pf) +{ +struct ice_vsi *pf_vsi =ice_get_main_vsi (pf); + +if (!pf_vsi) +return ; + +ice_tc_indir_block_unregister (pf_vsi); +} + +/** +* ice_tc_indir_block_register - Register TC indirect block notifications +* @vsi: VSI struct which has the netdev +* +* Returns 0 on success, negative value on failure +*/ +static int ice_tc_indir_block_register (struct ice_vsi *vsi) +{ +struct ice_netdev_priv *np; + +if (!vsi || !vsi->netdev) +return -EINVAL ; + + np =netdev_priv (vsi->netdev); + +INIT_LIST_HEAD (&np->tc_indr_block_priv_list); +return flow_indr_dev_register (ice_indr_setup_tc_cb, np); +} +/** * ice_setup_pf_sw - Setup the HW switch on startup or after reset * @pf: board private structure @@ -3407,6 +3470,7 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,*/ static int ice_setup_pf_sw (struct ice_pf *pf) { +struct device *dev =ice_pf_to_dev (pf);struct ice_vsi *vsi;int status =0 ;@@ -3425,6 +3489,13 @@ static int ice_setup_pf_sw(struct ice_pf *pf)/* netdev has to be configured before setting frame size */ ice_vsi_cfg_frame_size (vsi); +/* init indirect block notifications */ + status =ice_tc_indir_block_register (vsi); +if (status) { +dev_err (dev,"Failed to register netdev notifier\n" ); + goto unroll_cfg_netdev; + } +/* Setup DCB netlink interface */ ice_dcbnl_setup (vsi);@@ -3436,7 +3507,7 @@ static int ice_setup_pf_sw(struct ice_pf *pf) status =ice_set_cpu_rx_rmap (vsi);if (status) { -dev_err (ice_pf_to_dev (pf),"Failed to set CPU Rx map VSI %d error %d\n" , +dev_err (dev,"Failed to set CPU Rx map VSI %d error %d\n" , vsi->vsi_num, status); status = -EINVAL ; goto unroll_napi_add;@@ -3449,8 +3520,9 @@ static int ice_setup_pf_sw(struct ice_pf *pf) free_cpu_rx_map:ice_free_cpu_rx_rmap (vsi); - unroll_napi_add: +ice_tc_indir_block_unregister (vsi); +unroll_cfg_netdev:if (vsi) {ice_napi_del (vsi);if (vsi->netdev) {@@ -4727,6 +4799,8 @@ static void ice_remove(struct pci_dev *pdev)msleep (100 ); } +ice_tc_indir_block_remove (pf); +if (test_bit (ICE_FLAG_SRIOV_ENA , pf->flags)) {set_bit (ICE_VF_RESETS_DISABLED , pf->state);ice_free_vfs (pf);@@ -7272,6 +7346,126 @@ ice_setup_tc(struct net_device *netdev, enum tc_setup_type type,return -EOPNOTSUPP ; } +static struct ice_indr_block_priv * +ice_indr_block_priv_lookup (struct ice_netdev_priv *np, +struct net_device *netdev) +{ +struct ice_indr_block_priv *cb_priv; + +/* All callback list access should be protected by RTNL. */ +ASSERT_RTNL (); + +list_for_each_entry (cb_priv, &np->tc_indr_block_priv_list, list) { +if (!cb_priv->netdev) +return NULL ; +if (cb_priv->netdev == netdev) +return cb_priv; + } +return NULL ; +} + +static int +ice_indr_setup_block_cb (enum tc_setup_type type,void *type_data, +void *indr_priv) +{ +struct ice_indr_block_priv *priv = indr_priv; +struct ice_netdev_priv *np = priv->np; + +switch (type) { +case TC_SETUP_CLSFLOWER : +return ice_setup_tc_cls_flower (np, priv->netdev, + (struct flow_cls_offload *) + type_data); +default : +return -EOPNOTSUPP ; + } +} + +static int +ice_indr_setup_tc_block (struct net_device *netdev,struct Qdisc *sch, +struct ice_netdev_priv *np, +struct flow_block_offload *f,void *data, +void (*cleanup)(struct flow_block_cb *block_cb)) +{ +struct ice_indr_block_priv *indr_priv; +struct flow_block_cb *block_cb; + +int tunnel_type =0 ; + + if (tunnel_type != TNL_VXLAN && tunnel_type != TNL_GENEVE &&
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_main.c ice_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 7400
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_main.c +5
-0+ !(is_vlan_dev (netdev) && + vlan_dev_real_dev(netdev) == np->vsi->netdev)) + return -EOPNOTSUPP; + +if (f->binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS )Could you please document in the commit message, why other types are not supported?
There are no supported, becasue we can't offload it. For now we only support ingress type of filters.
Thanks for Your review.
Quoted 99 lines
Quoted 78 lines
drivers/net/ethernet/intel/ice/ice_main.c +68
-0+return -EOPNOTSUPP ; + +switch (f->command) { +case FLOW_BLOCK_BIND : + indr_priv =ice_indr_block_priv_lookup (np, netdev); +if (indr_priv) +return -EEXIST ; + + indr_priv =kzalloc (sizeof (*indr_priv),GFP_KERNEL ); +if (!indr_priv) +return -ENOMEM ; + + indr_priv->netdev = netdev; + indr_priv->np = np; +list_add (&indr_priv->list, &np->tc_indr_block_priv_list); + + block_cb = +flow_indr_block_cb_alloc (ice_indr_setup_block_cb, + indr_priv, indr_priv, + ice_rep_indr_tc_block_unbind, + f, netdev, sch, data, np, + cleanup); + +if (IS_ERR (block_cb)) { +list_del (&indr_priv->list); +kfree (indr_priv); +return PTR_ERR (block_cb); + } +flow_block_cb_add (block_cb, f); +list_add_tail (&block_cb->driver_list, &ice_block_cb_list); +return 0 ; +case FLOW_BLOCK_UNBIND : + indr_priv =ice_indr_block_priv_lookup (np, netdev); +if (!indr_priv) +return -ENOENT ; + + block_cb =flow_block_cb_lookup (f->block, + ice_indr_setup_block_cb, + indr_priv); +if (!block_cb) +return -ENOENT ; + +flow_indr_block_cb_remove (block_cb, f); + +list_del (&block_cb->driver_list); +return 0 ; +default : +return -EOPNOTSUPP ; + } +return 0 ; +} + +static int +ice_indr_setup_tc_cb (struct net_device *netdev,struct Qdisc *sch, +void *cb_priv,enum tc_setup_type type,void *type_data, +void *data, +void (*cleanup)(struct flow_block_cb *block_cb)) +{ +switch (type) { +case TC_SETUP_BLOCK : +return ice_indr_setup_tc_block (netdev, sch, cb_priv, type_data, + data, cleanup); + +default : +return -EOPNOTSUPP ; + } +} +/** * ice_open - Called when a network interface becomes active * @netdev: network interface device structure drivers/net/ethernet/intel/ice/ice_tc_lib.h +0
-0@@ -23,6 +23,12 @@#define ICE_TC_FLWR_FIELD_ENC_DST_MAC BIT(16)#define ICE_TC_FLWR_FIELD_ETH_TYPE_ID BIT(17)drivers/net/ethernet/intel/ice/ice_tc_lib.h line 34
Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_tc_lib.h +6
-0+struct ice_indr_block_priv { +struct net_device *netdev; +struct ice_netdev_priv *np; +struct list_head list; +}; +struct ice_tc_flower_action {u32 tc_class;enum ice_sw_fwd_act_type fltr_act;Acked-by Paul Menzel <[email protected]>Kind regards,
Paul
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Penigalapati
PATCH v2 1/4 ice: support for indirect notification
In reply to Tony NguyenQuoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Wednesday, October 13, 2021 12:01 AM
Quoted 11 lines
Subject: [Intel-wired-lan] [next-queue v2 1/4] ice: support for indirect notification
From: Michal Swiatkowski <[email protected]>
Implement indirect notification mechanism to support offloading TC rules on tunnel devices.
Keep indirect block list in netdev priv. Notification will call setting tc cls flower function.
Quoted 7 lines
Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice.h | 8 + drivers/net/ethernet/intel/ice/ice_main.c | 198 +++++++++++++++++++- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 6 + 3 files changed, 210 insertions(+), 2 deletions(-)
Tony Nguyen
maintainerPATCH v2 2/4 ice: VXLAN and Geneve TC support
In reply to Tony NguyenFrom: Michal Swiatkowski <[email protected]>
Add definition for VXLAN and Geneve dummy packet. Define VXLAN and Geneve type of fields to match on correct UDP tunnel header.
Parse tunnel specific fields from TC tool like outer MACs, outer IPs, outer destination port and VNI. Save values and masks in outer header struct and move header pointer to inner to simplify parsing inner values.
There are two cases for redirect action:
- from uplink to VF - TC filter is added on tunnel device
- from VF to uplink - TC filter is added on PR, for this case check if redirect device is tunnel device
VXLAN example:
- create tunnel device
ip l add $VXLAN_DEV type vxlan id $VXLAN_VNI dstport $VXLAN_PORT \
dev $PF
- add TC filter (in switchdev mode)
tc filter add dev $VXLAN_DEV protocol ip parent ffff: flower \enc_dst_ip $VF1_IP enc_key_id $VXLAN_VNI action mirred egress \
redirect dev $VF1_PR
Geneve example:
- create tunnel device
ip l add $GENEVE_DEV type geneve id $GENEVE_VNI dstport $GENEVE_PORT \
remote $GENEVE_IP
- add TC filter (in switchdev mode)
tc filter add dev $GENEVE_DEV protocol ip parent ffff: flower \enc_key_id $GENEVE_VNI dst_ip $GENEVE1_IP action mirred egress \
redirect dev $VF1_PR
--- drivers/net/ethernet/intel/ice/ice_main.c | 6 +- .../ethernet/intel/ice/ice_protocol_type.h | 16 + drivers/net/ethernet/intel/ice/ice_switch.h | 1 + drivers/net/ethernet/intel/ice/ice_tc_lib.c | 384 ++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_tc_lib.h | 4 + 5 files changed, 363 insertions(+), 48 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +2 -4
@@ -7390,11 +7390,9 @@ ice_indr_setup_tc_block(struct net_device *netdev, struct Qdisc *sch,struct ice_indr_block_priv *indr_priv;struct flow_block_cb *block_cb; -int tunnel_type =0 ; - -if (tunnel_type !=TNL_VXLAN && tunnel_type !=TNL_GENEVE && +if (!ice_is_tunnel_supported (netdev) && !(is_vlan_dev (netdev) && -vlan_dev_real_dev (netdev) == np->vsi->netdev)) +vlan_dev_real_dev (netdev) == np->vsi->netdev))return -EOPNOTSUPP ;if (f->binder_type !=FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS )
drivers/net/ethernet/intel/ice/ice_protocol_type.h +16 -0
@@ -37,10 +37,19 @@ enum ice_protocol_type {ICE_TCP_IL ,ICE_UDP_OF ,ICE_UDP_ILOS , +ICE_VXLAN , +ICE_GENEVE , +ICE_VXLAN_GPE ,ICE_SCTP_IL , ICE_PROTOCOL_LAST }; +enum ice_sw_tunnel_type { +ICE_NON_TUN =0 , +ICE_SW_TUN_VXLAN , +ICE_SW_TUN_GENEVE , +}; +/* Decoders for ice_prot_id: * - F: First * - I: Inner
@@ -152,6 +161,12 @@ struct ice_l4_hdr {__be16 check; }; +struct ice_udp_tnl_hdr { +__be16 field; +__be16 proto_type; +__be32 vni;/* only use lower 24-bits */ +}; +union ice_prot_hdr {struct ice_ether_hdr eth_hdr;struct ice_ethtype_hdr ethertype;
@@ -160,6 +175,7 @@ union ice_prot_hdr {struct ice_ipv6_hdr ipv6_hdr;struct ice_l4_hdr l4_hdr;struct ice_sctp_hdr sctp_hdr; +struct ice_udp_tnl_hdr tnl_hdr; };/* This is mapping table entry that maps every word within a given protocol
drivers/net/ethernet/intel/ice/ice_switch.h +1 -0
@@ -171,6 +171,7 @@ struct ice_adv_rule_flags_info { };struct ice_adv_rule_info { +enum ice_sw_tunnel_type tun_type;struct ice_sw_act_ctrl sw_act;u32 priority;u8 rx;/* true means LOOKUP_RX otherwise LOOKUP_TX */
drivers/net/ethernet/intel/ice/ice_tc_lib.c +340 -44
561 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_tc_lib.h +4 -0
@@ -23,6 +23,8 @@#define ICE_TC_FLWR_FIELD_ENC_DST_MAC BIT(16)#define ICE_TC_FLWR_FIELD_ETH_TYPE_ID BIT(17) +#define ICE_TC_FLOWER_MASK_32 0xFFFFFFFF +struct ice_indr_block_priv {struct net_device *netdev;struct ice_netdev_priv *np;
@@ -118,6 +120,7 @@ struct ice_tc_flower_fltr {struct ice_vsi *src_vsi;__be32 tenant_id;u32 flags; +u8 tunnel_type;struct ice_tc_flower_action action;/* cache ptr which is used wherever needed to communicate netlink
@@ -132,5 +135,6 @@ ice_add_cls_flower(struct net_device *netdev, struct ice_vsi *vsi,int ice_del_cls_flower (struct ice_vsi *vsi,struct flow_cls_offload *cls_flower);void ice_replay_tc_fltrs (struct ice_pf *pf); +bool ice_is_tunnel_supported (struct net_device *dev);#endif /* _ICE_TC_LIB_H_ */
Signature · 1 line
2.31.1
Tony Nguyen
maintainerPATCH v2 3/4 ice: low level support for tunnels
In reply to Tony NguyenFrom: Michal Swiatkowski <[email protected]>
Add definition of UDP tunnel dummy packets. Fill destination port value in filter based on UDP tunnel port. Append tunnel flags to switch filter definition in case of matching the tunnel.
Both vxlan and geneve are UDP tunnels, so only one new header is needed.
--- .../net/ethernet/intel/ice/ice_flex_pipe.c | 26 +- .../net/ethernet/intel/ice/ice_flex_type.h | 2 + .../ethernet/intel/ice/ice_protocol_type.h | 9 + drivers/net/ethernet/intel/ice/ice_switch.c | 264 +++++++++++++++++- drivers/net/ethernet/intel/ice/ice_switch.h | 2 + 5 files changed, 300 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_flex_pipe.c +25 -1
@@ -1641,6 +1641,26 @@ static struct ice_buf_build *ice_pkg_buf_alloc(struct ice_hw *hw)return bld; } +/** +* ice_get_sw_prof_type - determine switch profile type +* @hw: pointer to the HW structure +* @fv: pointer to the switch field vector +*/ +static enum ice_prof_type +ice_get_sw_prof_type (struct ice_hw *hw,struct ice_fv *fv) +{ +u16 i; + +for (i =0 ; i < hw->blk[ICE_BLK_SW ].es.fvw; i++) { +/* UDP tunnel will have UDP_OF protocol ID and VNI offset */ +if (fv->ew[i].prot_id == (u8 )ICE_PROT_UDP_OF && + fv->ew[i].off ==ICE_VNI_OFFSET ) +return ICE_PROF_TUN_UDP ; + } + +return ICE_PROF_NON_TUN ; +} +/** * ice_get_sw_fv_bitmap - Get switch field vector bitmap based on profile type * @hw: pointer to hardware structure
@@ -1664,6 +1684,7 @@ ice_get_sw_fv_bitmap(struct ice_hw *hw, enum ice_prof_type req_profs,bitmap_zero (bm,ICE_MAX_NUM_PROFILES ); ice_seg = hw->seg; do { + enum ice_prof_type prof_type; u32 offset; fv = ice_pkg_enum_entry(ice_seg, &state, ICE_SID_FLD_VEC_SW,
@@ -1671,7 +1692,10 @@ ice_get_sw_fv_bitmap(struct ice_hw *hw, enum ice_prof_type req_profs, ice_seg =NULL ;if (fv) { -if (req_profs &ICE_PROF_NON_TUN ) +/* Determine field vector type */ + prof_type =ice_get_sw_prof_type (hw, fv); + +if (req_profs & prof_type)set_bit ((u16 )offset, bm); } }while (fv);
drivers/net/ethernet/intel/ice/ice_flex_type.h +2 -0
@@ -656,6 +656,8 @@ struct ice_chs_chg {enum ice_prof_type {ICE_PROF_NON_TUN =0x1 , +ICE_PROF_TUN_UDP =0x2 , +ICE_PROF_TUN_ALL =0x6 ,ICE_PROF_ALL =0xFF , };#endif /* _ICE_FLEX_TYPE_H_ */
drivers/net/ethernet/intel/ice/ice_protocol_type.h +9 -0
@@ -48,6 +48,7 @@ enum ice_sw_tunnel_type {ICE_NON_TUN =0 ,ICE_SW_TUN_VXLAN ,ICE_SW_TUN_GENEVE , + ICE_ALL_TUNNELS /* All tunnel types including NVGRE */ };/* Decoders for ice_prot_id:
@@ -83,6 +84,8 @@ enum ice_prot_id { ICE_PROT_INVALID = 255 /* when offset == ICE_FV_OFFSET_INVAL */ }; +#define ICE_VNI_OFFSET 12/* offset of VNI from ICE_PROT_UDP_OF */ +#define ICE_MAC_OFOS_HW 1#define ICE_MAC_IL_HW 4#define ICE_ETYPE_OL_HW 9
@@ -96,6 +99,12 @@ enum ice_prot_id {#define ICE_UDP_ILOS_HW 53#define ICE_UDP_OF_HW 52/* UDP Tunnels */ +#define ICE_META_DATA_ID_HW 255/* this is used for tunnel type */ + +#define ICE_MDID_SIZE 2 +#define ICE_TUN_FLAG_MDID 21 +#define ICE_TUN_FLAG_MDID_OFF (ICE_MDID_SIZE * ICE_TUN_FLAG_MDID) +#define ICE_TUN_FLAG_MASK 0xFF#define ICE_TUN_FLAG_FV_IND 2
drivers/net/ethernet/intel/ice/ice_switch.c +262 -2
368 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_switch.h +2 -0
@@ -212,6 +212,8 @@ struct ice_sw_recipe {/* Bit map specifying the IDs associated with this group of recipe */ DECLARE_BITMAP (r_bitmap,ICE_MAX_NUM_RECIPES ); +enum ice_sw_tunnel_type tun_type; +/* List of type ice_fltr_mgmt_list_entry or adv_rule */ u8 adv_rule;struct list_head filt_rules;
Signature · 1 line
2.31.1
Penigalapati
PATCH v2 3/4 ice: low level support for tunnels
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Wednesday, October 13, 2021 12:01 AM
Quoted 10 lines
Subject: [Intel-wired-lan] [next-queue v2 3/4] ice: low level support for tunnels
From: Michal Swiatkowski <[email protected]>
Add definition of UDP tunnel dummy packets. Fill destination port value in filter based on UDP tunnel port. Append tunnel flags to switch filter definition in case of matching the tunnel.
Both vxlan and geneve are UDP tunnels, so only one new header is needed.
Quoted 9 lines
Signed-off-by Michal Swiatkowski <[email protected]>---
.../net/ethernet/intel/ice/ice_flex_pipe.c | 26 +- .../net/ethernet/intel/ice/ice_flex_type.h | 2 + .../ethernet/intel/ice/ice_protocol_type.h | 9 + drivers/net/ethernet/intel/ice/ice_switch.c | 264 +++++++++++++++++- drivers/net/ethernet/intel/ice/ice_switch.h | 2 + 5 files changed, 300 insertions(+), 3 deletions(-)
Tony Nguyen
maintainerPATCH v2 4/4 ice: support for GRE in eswitch
In reply to Tony NguyenFrom: Michal Swiatkowski <[email protected]>
Mostly reuse code from geneve and vxlan in TC parsing code. Add new GRE header to match on correct fields. Create new dummy packets with GRE fields.
Instead of checking if any encap values are presented in TC flower, check if device is tunnel type or redirect is to tunnel device. This will allow adding all combination of rules. For example filters only with inner fields.
Return error in case device isn't tunnel but encap values are presented.
gre example:
- create tunnel device
ip l add $NVGRE_DEV type gretap remote $NVGRE_REM_IP local $VF1_IP \
dev $PF
- add tc filter (in switchdev mode)
tc filter add dev $NVGRE_DEV protocol ip parent ffff: flower dst_ip \
$NVGRE1_IP action mirred egress redirect dev $VF1_PR
--- .../net/ethernet/intel/ice/ice_flex_pipe.c | 4 + .../net/ethernet/intel/ice/ice_flex_type.h | 2 + .../ethernet/intel/ice/ice_protocol_type.h | 10 ++ drivers/net/ethernet/intel/ice/ice_switch.c | 111 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_tc_lib.c | 28 +++-- 5 files changed, 145 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_flex_pipe.c +4 -0
@@ -1656,6 +1656,10 @@ ice_get_sw_prof_type(struct ice_hw *hw, struct ice_fv *fv)if (fv->ew[i].prot_id == (u8 )ICE_PROT_UDP_OF && fv->ew[i].off ==ICE_VNI_OFFSET )return ICE_PROF_TUN_UDP ; + +/* GRE tunnel will have GRE protocol */ +if (fv->ew[i].prot_id == (u8 )ICE_PROT_GRE_OF ) +return ICE_PROF_TUN_GRE ; }return ICE_PROF_NON_TUN ;
drivers/net/ethernet/intel/ice/ice_flex_type.h +2 -0
@@ -415,6 +415,7 @@ struct ice_pkg_enum {enum ice_tunnel_type {TNL_VXLAN =0 ,TNL_GENEVE , +TNL_GRETAP , __TNL_TYPE_CNT,TNL_LAST =0xFF ,TNL_ALL =0xFF ,
@@ -657,6 +658,7 @@ struct ice_chs_chg {enum ice_prof_type {ICE_PROF_NON_TUN =0x1 ,ICE_PROF_TUN_UDP =0x2 , +ICE_PROF_TUN_GRE =0x4 ,ICE_PROF_TUN_ALL =0x6 ,ICE_PROF_ALL =0xFF , };
drivers/net/ethernet/intel/ice/ice_protocol_type.h +10 -0
@@ -39,6 +39,7 @@ enum ice_protocol_type {ICE_UDP_ILOS ,ICE_VXLAN ,ICE_GENEVE , +ICE_NVGRE ,ICE_VXLAN_GPE ,ICE_SCTP_IL ,ICE_PROTOCOL_LAST
@@ -48,6 +49,7 @@ enum ice_sw_tunnel_type {ICE_NON_TUN =0 ,ICE_SW_TUN_VXLAN ,ICE_SW_TUN_GENEVE , +ICE_SW_TUN_NVGRE , ICE_ALL_TUNNELS /* All tunnel types including NVGRE */ };
@@ -97,6 +99,7 @@ enum ice_prot_id {#define ICE_IPV6_IL_HW 41#define ICE_TCP_IL_HW 49#define ICE_UDP_ILOS_HW 53 +#define ICE_GRE_OF_HW 64#define ICE_UDP_OF_HW 52/* UDP Tunnels */ #define ICE_META_DATA_ID_HW 255/* this is used for tunnel type */
@@ -176,6 +179,12 @@ struct ice_udp_tnl_hdr {__be32 vni;/* only use lower 24-bits */ }; +struct ice_nvgre_hdr { +__be16 flags; +__be16 protocol; +__be32 tni_flow; +}; +union ice_prot_hdr {struct ice_ether_hdr eth_hdr;struct ice_ethtype_hdr ethertype;
@@ -185,6 +194,7 @@ union ice_prot_hdr {struct ice_l4_hdr l4_hdr;struct ice_sctp_hdr sctp_hdr;struct ice_udp_tnl_hdr tnl_hdr; +struct ice_nvgre_hdr nvgre_hdr; };/* This is mapping table entry that maps every word within a given protocol
drivers/net/ethernet/intel/ice/ice_switch.c +111 -0
159 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_tc_lib.c +18 -10
@@ -105,6 +105,8 @@ ice_proto_type_from_tunnel(enum ice_tunnel_type type)return ICE_VXLAN ;case TNL_GENEVE :return ICE_GENEVE ; +case TNL_GRETAP : +return ICE_NVGRE ;default :return 0 ; }
@@ -118,6 +120,8 @@ ice_sw_type_from_tunnel(enum ice_tunnel_type type)return ICE_SW_TUN_VXLAN ;case TNL_GENEVE :return ICE_SW_TUN_GENEVE ; +case TNL_GRETAP : +return ICE_SW_TUN_NVGRE ;default :return ICE_NON_TUN ; }
@@ -335,6 +339,9 @@ static int ice_tc_tun_get_type(struct net_device *tunnel_dev)return TNL_VXLAN ;if (netif_is_geneve (tunnel_dev))return TNL_GENEVE ; +if (netif_is_gretap (tunnel_dev) || +netif_is_ip6gretap (tunnel_dev)) +return TNL_GRETAP ;return TNL_LAST ; }
@@ -682,6 +689,7 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,struct flow_rule *rule =flow_cls_offload_flow_rule (f);u16 n_proto_mask =0 , n_proto_key =0 , addr_type =0 ;struct flow_dissector *dissector; +struct net_device *tunnel_dev; dissector = rule->match.dissector;
@@ -703,18 +711,11 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,return -EOPNOTSUPP ; } -if ((flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS ) || -flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS ) || -flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_KEYID ) || -flow_rule_match_key (rule,FLOW_DISSECTOR_KEY_ENC_PORTS ))) { + tunnel_dev =ice_get_tunnel_device (filter_dev, rule); +if (tunnel_dev) {int err; - filter_dev =ice_get_tunnel_device (filter_dev, rule); -if (!filter_dev) { -NL_SET_ERR_MSG_MOD (fltr->extack, -"Tunnel device not found" ); -return -EOPNOTSUPP ; - } + filter_dev = tunnel_dev; err =ice_parse_tunnel_attr (filter_dev, rule, fltr);if (err) {
@@ -727,6 +728,13 @@ ice_parse_cls_flower(struct net_device *filter_dev, struct ice_vsi *vsi,* header were already set by ice_parse_tunnel_attr */ headers = &fltr->inner_headers; + }else if (dissector->used_keys & + (BIT (FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS ) | +BIT (FLOW_DISSECTOR_KEY_ENC_KEYID ) | +BIT (FLOW_DISSECTOR_KEY_ENC_PORTS ))) { +NL_SET_ERR_MSG_MOD (fltr->extack,"Tunnel key used, but device isn't a tunnel" ); +return -EOPNOTSUPP ; }else { fltr->tunnel_type =TNL_LAST ; }
Signature · 1 line
2.31.1
Penigalapati
PATCH v2 4/4 ice: support for GRE in eswitch
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Wednesday, October 13, 2021 12:01 AM
Quoted 21 lines
Subject: [Intel-wired-lan] [next-queue v2 4/4] ice: support for GRE in eswitch
From: Michal Swiatkowski <[email protected]>
Mostly reuse code from geneve and vxlan in TC parsing code. Add new GRE header to match on correct fields. Create new dummy packets with GRE fields.
Instead of checking if any encap values are presented in TC flower, check if device is tunnel type or redirect is to tunnel device. This will allow adding all combination of rules. For example filters only with inner fields.
Return error in case device isn't tunnel but encap values are presented.
gre example:
- create tunnel device
ip l add $NVGRE_DEV type gretap remote $NVGRE_REM_IP local $VF1_IP \ dev $PF
- add tc filter (in switchdev mode)
tc filter add dev $NVGRE_DEV protocol ip parent ffff: flowerdst_ip\
$NVGRE1_IP action mirred egress redirect dev $VF1_PR
Quoted 9 lines
Signed-off-by Michal Swiatkowski <[email protected]>---
.../net/ethernet/intel/ice/ice_flex_pipe.c | 4 + .../net/ethernet/intel/ice/ice_flex_type.h | 2 + .../ethernet/intel/ice/ice_protocol_type.h | 10 ++ drivers/net/ethernet/intel/ice/ice_switch.c | 111 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_tc_lib.c | 28 +++-- 5 files changed, 145 insertions(+), 10 deletions(-)