net/mlx5e: Support offloading tc priorities and chains for eswitch flows
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_rep.c
index 9264c3332aa60faf6842b602d81cb4bc9fb10e28..c3c657548824117f1732f3c7d14158c9a2a8e2a0 100644 (file)
@@ -853,9 +853,6 @@ static int mlx5e_rep_setup_tc_cb_egdev(enum tc_setup_type type, void *type_data,
 {
        struct mlx5e_priv *priv = cb_priv;
 
-       if (!tc_cls_can_offload_and_chain0(priv->netdev, type_data))
-               return -EOPNOTSUPP;
-
        switch (type) {
        case TC_SETUP_CLSFLOWER:
                return mlx5e_rep_setup_tc_cls_flower(priv, type_data, MLX5E_TC_EGRESS);
@@ -869,9 +866,6 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
 {
        struct mlx5e_priv *priv = cb_priv;
 
-       if (!tc_cls_can_offload_and_chain0(priv->netdev, type_data))
-               return -EOPNOTSUPP;
-
        switch (type) {
        case TC_SETUP_CLSFLOWER:
                return mlx5e_rep_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS);
@@ -992,8 +986,7 @@ mlx5e_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
        struct mlx5e_priv *priv = netdev_priv(dev);
 
        /* update HW stats in background for next time */
-       queue_delayed_work(priv->wq, &priv->update_stats_work, 0);
-
+       mlx5e_queue_update_stats(priv);
        memcpy(stats, &priv->stats.vf_vport, sizeof(*stats));
 }
 
@@ -1078,28 +1071,33 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev)
        netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu);
 }
 
-static void mlx5e_init_rep(struct mlx5_core_dev *mdev,
-                          struct net_device *netdev,
-                          const struct mlx5e_profile *profile,
-                          void *ppriv)
+static int mlx5e_init_rep(struct mlx5_core_dev *mdev,
+                         struct net_device *netdev,
+                         const struct mlx5e_profile *profile,
+                         void *ppriv)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
+       int err;
 
-       priv->mdev                         = mdev;
-       priv->netdev                       = netdev;
-       priv->profile                      = profile;
-       priv->ppriv                        = ppriv;
-
-       mutex_init(&priv->state_lock);
+       err = mlx5e_netdev_init(netdev, priv, mdev, profile, ppriv);
+       if (err)
+               return err;
 
-       INIT_DELAYED_WORK(&priv->update_stats_work, mlx5e_update_stats_work);
 
-       priv->channels.params.num_channels = 1;
+       priv->channels.params.num_channels =
+                               mlx5e_get_netdev_max_channels(netdev);
 
        mlx5e_build_rep_params(mdev, &priv->channels.params, netdev->mtu);
        mlx5e_build_rep_netdev(netdev);
 
        mlx5e_timestamp_init(priv);
+
+       return 0;
+}
+
+static void mlx5e_cleanup_rep(struct mlx5e_priv *priv)
+{
+       mlx5e_netdev_cleanup(priv->netdev, priv);
 }
 
 static int mlx5e_create_rep_ttc_table(struct mlx5e_priv *priv)
@@ -1224,12 +1222,12 @@ static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
 
 static const struct mlx5e_profile mlx5e_rep_profile = {
        .init                   = mlx5e_init_rep,
+       .cleanup                = mlx5e_cleanup_rep,
        .init_rx                = mlx5e_init_rep_rx,
        .cleanup_rx             = mlx5e_cleanup_rep_rx,
        .init_tx                = mlx5e_init_rep_tx,
        .cleanup_tx             = mlx5e_cleanup_nic_tx,
        .update_stats           = mlx5e_rep_update_hw_counters,
-       .max_nch                = mlx5e_get_max_num_channels,
        .update_carrier         = NULL,
        .rx_handlers.handle_rx_cqe       = mlx5e_handle_rx_cqe_rep,
        .rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
@@ -1292,13 +1290,14 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
        struct mlx5e_rep_priv *rpriv;
        struct net_device *netdev;
        struct mlx5e_priv *upriv;
-       int err;
+       int nch, err;
 
        rpriv = kzalloc(sizeof(*rpriv), GFP_KERNEL);
        if (!rpriv)
                return -ENOMEM;
 
-       netdev = mlx5e_create_netdev(dev, &mlx5e_rep_profile, rpriv);
+       nch = mlx5e_get_max_num_channels(dev);
+       netdev = mlx5e_create_netdev(dev, &mlx5e_rep_profile, nch, rpriv);
        if (!netdev) {
                pr_warn("Failed to create representor netdev for vport %d\n",
                        rep->vport);