]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net/mlx5e: IPoIB, Add PKEY child interface nic profile
authorAlex Vesker <valex@mellanox.com>
Thu, 14 Sep 2017 11:08:39 +0000 (14:08 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Sat, 14 Oct 2017 18:22:10 +0000 (11:22 -0700)
Child interface profile will be called to support child interface
specific behaviour. The child code is sparse compared to the parent
since the RX channels are shared between the interfaces.
Creating a septate profile for child and parent will make a smother
code with a better ability for future expansion.
The profile stuct is exposed to the parent using a getter function.

Signed-off-by: Alex Vesker <valex@mellanox.com>
Reviewed-by: Erez Shitrit <erezsh@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.h
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c

index c479fe54a6caa32df911cd0184e0b23f83e64be6..196771cc599e2ae1f7d39b0a9d0468cc6508b5b5 100644 (file)
@@ -70,10 +70,10 @@ static void mlx5i_build_nic_params(struct mlx5_core_dev *mdev,
 }
 
 /* Called directly after IPoIB netdevice was created to initialize SW structs */
-static void mlx5i_init(struct mlx5_core_dev *mdev,
-                      struct net_device *netdev,
-                      const struct mlx5e_profile *profile,
-                      void *ppriv)
+void mlx5i_init(struct mlx5_core_dev *mdev,
+               struct net_device *netdev,
+               const struct mlx5e_profile *profile,
+               void *ppriv)
 {
        struct mlx5e_priv *priv  = mlx5i_epriv(netdev);
 
@@ -169,7 +169,7 @@ static void mlx5i_uninit_underlay_qp(struct mlx5e_priv *priv)
 
 #define MLX5_QP_ENHANCED_ULP_STATELESS_MODE 2
 
-static int mlx5i_create_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp)
+int mlx5i_create_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp)
 {
        u32 *in = NULL;
        void *addr_path;
@@ -203,7 +203,7 @@ static int mlx5i_create_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core
        return ret;
 }
 
-static void mlx5i_destroy_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp)
+void mlx5i_destroy_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp)
 {
        mlx5_core_destroy_qp(mdev, qp);
 }
index e313f6d90729dbd9742a159ccfcef2bc8da928b6..c9895f7a23586de48a3a86463ed2737f247ddf96 100644 (file)
@@ -55,6 +55,10 @@ struct mlx5i_priv {
        char  *mlx5e_priv[0];
 };
 
+/* Underlay QP create/destroy functions */
+int mlx5i_create_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp);
+void mlx5i_destroy_underlay_qp(struct mlx5_core_dev *mdev, struct mlx5_core_qp *qp);
+
 /* Allocate/Free underlay QPN to net-device hash table */
 int mlx5i_pkey_qpn_ht_init(struct net_device *netdev);
 void mlx5i_pkey_qpn_ht_cleanup(struct net_device *netdev);
@@ -66,6 +70,15 @@ int mlx5i_pkey_del_qpn(struct net_device *netdev, u32 qpn);
 /* Get the net-device corresponding to the given underlay QPN */
 struct net_device *mlx5i_pkey_get_netdev(struct net_device *netdev, u32 qpn);
 
+/* Parent profile functions */
+void mlx5i_init(struct mlx5_core_dev *mdev,
+               struct net_device *netdev,
+               const struct mlx5e_profile *profile,
+               void *ppriv);
+
+/* Get child interface nic profile */
+const struct mlx5e_profile *mlx5i_pkey_get_profile(void);
+
 /* Extract mlx5e_priv from IPoIB netdev */
 #define mlx5i_epriv(netdev) ((void *)(((struct mlx5i_priv *)netdev_priv(netdev))->mlx5e_priv))
 
index e4d39aa1f552350d3da2c43fc7fd36edd8ccc99f..17c508d98dbbfbdc9391bcc2a6ad889f64c2748b 100644 (file)
@@ -134,3 +134,86 @@ struct net_device *mlx5i_pkey_get_netdev(struct net_device *netdev, u32 qpn)
 
        return node->netdev;
 }
+
+/* Called directly after IPoIB netdevice was created to initialize SW structs */
+static void mlx5i_pkey_init(struct mlx5_core_dev *mdev,
+                            struct net_device *netdev,
+                            const struct mlx5e_profile *profile,
+                            void *ppriv)
+{
+       struct mlx5e_priv *priv  = mlx5i_epriv(netdev);
+
+       mlx5i_init(mdev, netdev, profile, ppriv);
+
+       /* Override parent ndo */
+       netdev->netdev_ops = NULL;
+
+       /* Currently no ethtool support */
+       netdev->ethtool_ops = NULL;
+
+       /* Use dummy rqs */
+       priv->channels.params.log_rq_size = MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE;
+}
+
+/* Called directly before IPoIB netdevice is destroyed to cleanup SW structs */
+static void mlx5i_pkey_cleanup(struct mlx5e_priv *priv)
+{
+       /* Do nothing .. */
+}
+
+static int mlx5i_pkey_init_tx(struct mlx5e_priv *priv)
+{
+       struct mlx5i_priv *ipriv = priv->ppriv;
+       int err;
+
+       err = mlx5i_create_underlay_qp(priv->mdev, &ipriv->qp);
+       if (err) {
+               mlx5_core_warn(priv->mdev, "create child underlay QP failed, %d\n", err);
+               return err;
+       }
+
+       return 0;
+}
+
+static void mlx5i_pkey_cleanup_tx(struct mlx5e_priv *priv)
+{
+       struct mlx5i_priv *ipriv = priv->ppriv;
+
+       mlx5i_destroy_underlay_qp(priv->mdev, &ipriv->qp);
+}
+
+static int mlx5i_pkey_init_rx(struct mlx5e_priv *priv)
+{
+       /* Since the rx resources are shared between child and parent, the
+        * parent interface is taking care of rx resource allocation and init
+        */
+       return 0;
+}
+
+static void mlx5i_pkey_cleanup_rx(struct mlx5e_priv *priv)
+{
+       /* Since the rx resources are shared between child and parent, the
+        * parent interface is taking care of rx resource free and de-init
+        */
+}
+
+static const struct mlx5e_profile mlx5i_pkey_nic_profile = {
+       .init              = mlx5i_pkey_init,
+       .cleanup           = mlx5i_pkey_cleanup,
+       .init_tx           = mlx5i_pkey_init_tx,
+       .cleanup_tx        = mlx5i_pkey_cleanup_tx,
+       .init_rx           = mlx5i_pkey_init_rx,
+       .cleanup_rx        = mlx5i_pkey_cleanup_rx,
+       .enable            = NULL,
+       .disable           = NULL,
+       .update_stats      = NULL,
+       .max_nch           = mlx5e_get_max_num_channels,
+       .rx_handlers.handle_rx_cqe       = mlx5i_handle_rx_cqe,
+       .rx_handlers.handle_rx_cqe_mpwqe = NULL, /* Not supported */
+       .max_tc            = MLX5I_MAX_NUM_TC,
+};
+
+const struct mlx5e_profile *mlx5i_pkey_get_profile(void)
+{
+       return &mlx5i_pkey_nic_profile;
+}