All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Cc: linux-rdma@vger.kernel.org, Doug Ledford <dledford@redhat.com>,
	Leon Romanovsky <leonro@mellanox.com>,
	Erez Shitrit <erezsh@mellanox.com>,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	Vishwanathapura Niranjana <niranjana.vishwanathapura@intel.com>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: [PATCH net-next 13/16] net/mlx5e: RX handlers per netdev profile
Date: Thu, 13 Apr 2017 06:37:03 +0300	[thread overview]
Message-ID: <20170413033706.19016-14-saeedm@mellanox.com> (raw)
In-Reply-To: <20170413033706.19016-1-saeedm@mellanox.com>

In order to have different RX handler per profile, fix and refactor the
current code to take the rx handler directly from the netdevice profile
rather than computing it on runtime as it was done with the switchdev
mode representor rx handler.

This will also remove the current wrong assumption in mlx5e_alloc_rq
code that mlx5e_priv->ppriv is of the type vport_rep.

Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Erez Shitrit <erezsh@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h      |  5 +++-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 28 ++++++++++++++---------
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c  |  4 +++-
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 25185f8c3562..0881325fba04 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -779,6 +779,10 @@ struct mlx5e_profile {
 	void	(*disable)(struct mlx5e_priv *priv);
 	void	(*update_stats)(struct mlx5e_priv *priv);
 	int	(*max_nch)(struct mlx5_core_dev *mdev);
+	struct {
+		mlx5e_fp_handle_rx_cqe handle_rx_cqe;
+		mlx5e_fp_handle_rx_cqe handle_rx_cqe_mpwqe;
+	} rx_handlers;
 	int	max_tc;
 };
 
@@ -1032,7 +1036,6 @@ int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev,
 bool mlx5e_has_offload_stats(const struct net_device *dev, int attr_id);
 
 bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv);
-bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv);
 
 /* mlx5e generic netdev management API */
 struct net_device*
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 2201b7ea05f4..6a164aff404c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -585,15 +585,17 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
 
 	switch (rq->wq_type) {
 	case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
-		if (mlx5e_is_vf_vport_rep(c->priv)) {
-			err = -EINVAL;
-			goto err_rq_wq_destroy;
-		}
 
-		rq->handle_rx_cqe = mlx5e_handle_rx_cqe_mpwrq;
 		rq->alloc_wqe = mlx5e_alloc_rx_mpwqe;
 		rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe;
 
+		rq->handle_rx_cqe = c->priv->profile->rx_handlers.handle_rx_cqe_mpwqe;
+		if (!rq->handle_rx_cqe) {
+			err = -EINVAL;
+			netdev_err(c->netdev, "RX handler of MPWQE RQ is not set, err %d\n", err);
+			goto err_rq_wq_destroy;
+		}
+
 		rq->mpwqe_stride_sz = BIT(params->mpwqe_log_stride_sz);
 		rq->mpwqe_num_strides = BIT(params->mpwqe_log_num_strides);
 
@@ -616,15 +618,17 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
 			err = -ENOMEM;
 			goto err_rq_wq_destroy;
 		}
-
-		if (mlx5e_is_vf_vport_rep(c->priv))
-			rq->handle_rx_cqe = mlx5e_handle_rx_cqe_rep;
-		else
-			rq->handle_rx_cqe = mlx5e_handle_rx_cqe;
-
 		rq->alloc_wqe = mlx5e_alloc_rx_wqe;
 		rq->dealloc_wqe = mlx5e_dealloc_rx_wqe;
 
+		rq->handle_rx_cqe = c->priv->profile->rx_handlers.handle_rx_cqe;
+		if (!rq->handle_rx_cqe) {
+			kfree(rq->dma_info);
+			err = -EINVAL;
+			netdev_err(c->netdev, "RX handler of RQ is not set, err %d\n", err);
+			goto err_rq_wq_destroy;
+		}
+
 		rq->buff.wqe_sz = params->lro_en  ?
 				params->lro_wqe_sz :
 				MLX5E_SW2HW_MTU(c->netdev->mtu);
@@ -4229,6 +4233,8 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
 	.disable	   = mlx5e_nic_disable,
 	.update_stats	   = mlx5e_update_stats,
 	.max_nch	   = mlx5e_get_max_num_channels,
+	.rx_handlers.handle_rx_cqe       = mlx5e_handle_rx_cqe,
+	.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
 	.max_tc		   = MLX5E_MAX_NUM_TC,
 };
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index da85b0ad3e92..16b683e8226d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -329,7 +329,7 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
 	return false;
 }
 
-bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
+static bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
 {
 	struct mlx5_eswitch_rep *rep = (struct mlx5_eswitch_rep *)priv->ppriv;
 
@@ -538,6 +538,8 @@ static struct mlx5e_profile mlx5e_rep_profile = {
 	.cleanup_tx		= mlx5e_cleanup_nic_tx,
 	.update_stats           = mlx5e_rep_update_stats,
 	.max_nch		= mlx5e_get_rep_max_num_channels,
+	.rx_handlers.handle_rx_cqe       = mlx5e_handle_rx_cqe_rep,
+	.rx_handlers.handle_rx_cqe_mpwqe = NULL /* Not supported */,
 	.max_tc			= 1,
 };
 
-- 
2.11.0

  parent reply	other threads:[~2017-04-13  3:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13  3:36 [PATCH net-next 00/16] Mellanox, mlx5 RDMA net device support Saeed Mahameed
2017-04-13  3:36 ` [PATCH net-next 01/16] net/mlx5: Add IPoIB enhanced offloads bits to mlx5_ifc Saeed Mahameed
     [not found] ` <20170413033706.19016-1-saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-04-13  3:36   ` [PATCH net-next 02/16] net/mlx5: Refactor create flow table method to accept underlay QP Saeed Mahameed
2017-04-13  3:36   ` [PATCH net-next 03/16] net/mlx5: Enable flow-steering for IB link Saeed Mahameed
2017-04-13  3:36   ` [PATCH net-next 04/16] net/mlx5e: More generic netdev management API Saeed Mahameed
2017-04-13  3:36   ` [PATCH net-next 05/16] net/mlx5e: IPoIB, Add netdevice profile skeleton Saeed Mahameed
2017-04-13  3:36   ` [PATCH net-next 07/16] net/mlx5e: IPoIB, RSS flow steering tables Saeed Mahameed
2017-04-13  3:36   ` [PATCH net-next 09/16] net/mlx5e: IPoIB, Basic netdev ndos open/close Saeed Mahameed
2017-04-13  3:37   ` [PATCH net-next 10/16] net/mlx5e: IPoIB, Underlay QP Saeed Mahameed
2017-04-13  3:37   ` [PATCH net-next 11/16] net/mlx5e: Xmit flow break down Saeed Mahameed
2017-04-13  3:37   ` [PATCH net-next 14/16] net/mlx5e: IPoIB, RX handler Saeed Mahameed
2017-04-13  3:37   ` [PATCH net-next 15/16] net/mlx5e: E-switch vport manager is valid for ethernet only Saeed Mahameed
2017-04-13  3:36 ` [PATCH net-next 06/16] net/mlx5e: IPoIB, RX steering RSS RQTs and TIRs Saeed Mahameed
2017-04-13  3:36 ` [PATCH net-next 08/16] net/mlx5e: IPoIB, TX TIS creation Saeed Mahameed
2017-04-13  3:37 ` [PATCH net-next 12/16] net/mlx5e: IPoIB, Xmit flow Saeed Mahameed
2017-04-13  3:37 ` Saeed Mahameed [this message]
2017-04-13  3:37 ` [PATCH net-next 16/16] hw/mlx5: Add New bit to check over QP creation Saeed Mahameed
2017-04-17 15:08 ` [PATCH net-next 00/16] Mellanox, mlx5 RDMA net device support David Miller
2017-04-20 18:41   ` Doug Ledford
     [not found]     ` <1492713677.3041.3.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-04-20 18:49       ` Leon Romanovsky
2017-04-20 18:49         ` Leon Romanovsky
     [not found]         ` <20170420184955.GU14088-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-04-20 20:45           ` Doug Ledford
     [not found]             ` <1492721143.3041.20.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-04-21  2:32               ` Leon Romanovsky
2017-04-21  2:32                 ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170413033706.19016-14-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=dledford@redhat.com \
    --cc=erezsh@mellanox.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=niranjana.vishwanathapura@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.