]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ice: ndo_setup_tc implementation for PR
authorMichal Swiatkowski <michal.swiatkowski@intel.com>
Fri, 6 Aug 2021 08:49:06 +0000 (10:49 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 11 Oct 2021 16:03:08 +0000 (09:03 -0700)
Add tc-flower support for VF port representor devices.

Implement ndo_setup_tc callback for TC HW offload on VF port representors
devices. Implemented both methods: add and delete tc-flower flows.

Mark NETIF_F_HW_TC bit in net device's feature set to enable offload TC
infrastructure for port representor.

Implement TC filters replay function required to restore filters settings
while switchdev configuration is rebuilt.

Signed-off-by: Michal Swiatkowski <michal.swiatkowski@intel.com>
Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
Tested-by: Sandeep Penigalapati <sandeep.penigalapati@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_eswitch.c
drivers/net/ethernet/intel/ice/ice_repr.c
drivers/net/ethernet/intel/ice/ice_tc_lib.c
drivers/net/ethernet/intel/ice/ice_tc_lib.h

index 477e3f2d616d2447dce6df59e256f4b4b6aabd4d..d91a7834f91f70893c2fa5a0e8903f93f5b50f8f 100644 (file)
@@ -7,6 +7,7 @@
 #include "ice_fltr.h"
 #include "ice_repr.h"
 #include "ice_devlink.h"
+#include "ice_tc_lib.h"
 
 /**
  * ice_eswitch_setup_env - configure switchdev HW filters
@@ -645,6 +646,8 @@ int ice_eswitch_rebuild(struct ice_pf *pf)
 
        ice_eswitch_remap_rings_to_vectors(pf);
 
+       ice_replay_tc_fltrs(pf);
+
        status = ice_vsi_open(ctrl_vsi);
        if (status)
                return status;
index cb83f58d7c713c24e407e5fd30b99c16502f8110..c49eeea7cb6762c25ef0e1dd7267d29d1b44ab63 100644 (file)
@@ -5,6 +5,7 @@
 #include "ice_eswitch.h"
 #include "ice_devlink.h"
 #include "ice_virtchnl_pf.h"
+#include "ice_tc_lib.h"
 
 /**
  * ice_repr_get_sw_port_id - get port ID associated with representor
@@ -141,6 +142,55 @@ ice_repr_get_devlink_port(struct net_device *netdev)
        return &repr->vf->devlink_port;
 }
 
+static int
+ice_repr_setup_tc_cls_flower(struct ice_repr *repr,
+                            struct flow_cls_offload *flower)
+{
+       switch (flower->command) {
+       case FLOW_CLS_REPLACE:
+               return ice_add_cls_flower(repr->netdev, repr->src_vsi, flower);
+       case FLOW_CLS_DESTROY:
+               return ice_del_cls_flower(repr->src_vsi, flower);
+       default:
+               return -EINVAL;
+       }
+}
+
+static int
+ice_repr_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
+                          void *cb_priv)
+{
+       struct flow_cls_offload *flower = (struct flow_cls_offload *)type_data;
+       struct ice_netdev_priv *np = (struct ice_netdev_priv *)cb_priv;
+
+       switch (type) {
+       case TC_SETUP_CLSFLOWER:
+               return ice_repr_setup_tc_cls_flower(np->repr, flower);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
+static LIST_HEAD(ice_repr_block_cb_list);
+
+static int
+ice_repr_setup_tc(struct net_device *netdev, enum tc_setup_type type,
+                 void *type_data)
+{
+       struct ice_netdev_priv *np = netdev_priv(netdev);
+
+       switch (type) {
+       case TC_SETUP_BLOCK:
+               return flow_block_cb_setup_simple((struct flow_block_offload *)
+                                                 type_data,
+                                                 &ice_repr_block_cb_list,
+                                                 ice_repr_setup_tc_block_cb,
+                                                 np, np, true);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
 static const struct net_device_ops ice_repr_netdev_ops = {
        .ndo_get_phys_port_name = ice_repr_get_phys_port_name,
        .ndo_get_stats64 = ice_repr_get_stats64,
@@ -148,6 +198,7 @@ static const struct net_device_ops ice_repr_netdev_ops = {
        .ndo_stop = ice_repr_stop,
        .ndo_start_xmit = ice_eswitch_port_start_xmit,
        .ndo_get_devlink_port = ice_repr_get_devlink_port,
+       .ndo_setup_tc = ice_repr_setup_tc,
 };
 
 /**
@@ -170,6 +221,8 @@ ice_repr_reg_netdev(struct net_device *netdev)
        netdev->netdev_ops = &ice_repr_netdev_ops;
        ice_set_ethtool_repr_ops(netdev);
 
+       netdev->hw_features |= NETIF_F_HW_TC;
+
        netif_carrier_off(netdev);
        netif_tx_stop_all_queues(netdev);
 
index d2b6490efd6bd561ae2520ffed3bdda848f13301..4c1daa1a02a148dc7762d5ef9acc3f4d7493e5e5 100644 (file)
@@ -836,3 +836,20 @@ ice_del_cls_flower(struct ice_vsi *vsi, struct flow_cls_offload *cls_flower)
 
        return 0;
 }
+
+/**
+ * ice_replay_tc_fltrs - replay TC filters
+ * @pf: pointer to PF struct
+ */
+void ice_replay_tc_fltrs(struct ice_pf *pf)
+{
+       struct ice_tc_flower_fltr *fltr;
+       struct hlist_node *node;
+
+       hlist_for_each_entry_safe(fltr, node,
+                                 &pf->tc_flower_fltr_list,
+                                 tc_flower_node) {
+               fltr->extack = NULL;
+               ice_add_switch_fltr(fltr->src_vsi, fltr);
+       }
+}
index 883d2891f92c66e106b58c0e1f23fefb5616e030..d90e9e37ae25eb261fc753309e54b1b6b0f342f0 100644 (file)
@@ -125,5 +125,6 @@ ice_add_cls_flower(struct net_device *netdev, struct ice_vsi *vsi,
                   struct flow_cls_offload *cls_flower);
 int
 ice_del_cls_flower(struct ice_vsi *vsi, struct flow_cls_offload *cls_flower);
+void ice_replay_tc_fltrs(struct ice_pf *pf);
 
 #endif /* _ICE_TC_LIB_H_ */