netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com,
	mlxsw@mellanox.com, andrew@lunn.ch,
	vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com,
	michael.chan@broadcom.com, ganeshgr@chelsio.com,
	jeffrey.t.kirsher@intel.com, saeedm@mellanox.com,
	matanb@mellanox.com, leonro@mellanox.com, idosch@mellanox.com,
	jakub.kicinski@netronome.com, ast@kernel.org,
	daniel@iogearbox.net, simon.horman@netronome.com,
	pieter.jansenvanvuuren@netronome.com, john.hurley@netronome.com,
	alexander.h.duyck@intel.com
Subject: [patch net-next v2 11/20] bnxt: Convert ndo_setup_tc offloads to block callbacks
Date: Thu, 19 Oct 2017 15:50:39 +0200	[thread overview]
Message-ID: <20171019135048.4306-12-jiri@resnulli.us> (raw)
In-Reply-To: <20171019135048.4306-1-jiri@resnulli.us>

From: Jiri Pirko <jiri@mellanox.com>

Benefit from the newly introduced block callback infrastructure and
convert ndo_setup_tc calls for flower offloads to block callbacks.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c     | 37 +++++++++++++++++++----
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |  3 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 43 +++++++++++++++++++++++++--
 3 files changed, 73 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 5ba4993..4dde2b8 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -7295,15 +7295,40 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
 	return 0;
 }
 
-static int bnxt_setup_flower(struct net_device *dev,
-			     struct tc_cls_flower_offload *cls_flower)
+static int bnxt_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
+				  void *cb_priv)
 {
-	struct bnxt *bp = netdev_priv(dev);
+	struct bnxt *bp = cb_priv;
 
 	if (BNXT_VF(bp))
 		return -EOPNOTSUPP;
 
-	return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, cls_flower);
+	switch (type) {
+	case TC_SETUP_CLSFLOWER:
+		return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, type_data);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static int bnxt_setup_tc_block(struct net_device *dev,
+			       struct tc_block_offload *f)
+{
+	struct bnxt *bp = netdev_priv(dev);
+
+	if (f->binder_type != TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
+		return -EOPNOTSUPP;
+
+	switch (f->command) {
+	case TC_BLOCK_BIND:
+		return tcf_block_cb_register(f->block, bnxt_setup_tc_block_cb,
+					     bp, bp);
+	case TC_BLOCK_UNBIND:
+		tcf_block_cb_unregister(f->block, bnxt_setup_tc_block_cb, bp);
+		return 0;
+	default:
+		return -EOPNOTSUPP;
+	}
 }
 
 static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,
@@ -7311,7 +7336,9 @@ static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,
 {
 	switch (type) {
 	case TC_SETUP_CLSFLOWER:
-		return bnxt_setup_flower(dev, type_data);
+		return 0; /* will be removed after conversion from ndo */
+	case TC_SETUP_BLOCK:
+		return bnxt_setup_tc_block(dev, type_data);
 	case TC_SETUP_MQPRIO: {
 		struct tc_mqprio_qopt *mqprio = type_data;
 
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
index 4730c04..a9cb653 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
@@ -748,8 +748,7 @@ int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
 {
 	int rc = 0;
 
-	if (!is_classid_clsact_ingress(cls_flower->common.classid) ||
-	    cls_flower->common.chain_index)
+	if (cls_flower->common.chain_index)
 		return -EOPNOTSUPP;
 
 	switch (cls_flower->command) {
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
index e75db04..cc278d7 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
@@ -115,10 +115,11 @@ bnxt_vf_rep_get_stats64(struct net_device *dev,
 	stats->tx_bytes = vf_rep->tx_stats.bytes;
 }
 
-static int bnxt_vf_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
-				void *type_data)
+static int bnxt_vf_rep_setup_tc_block_cb(enum tc_setup_type type,
+					 void *type_data,
+					 void *cb_priv)
 {
-	struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
+	struct bnxt_vf_rep *vf_rep = cb_priv;
 	struct bnxt *bp = vf_rep->bp;
 	int vf_fid = bp->pf.vf[vf_rep->vf_idx].fw_fid;
 
@@ -130,6 +131,42 @@ static int bnxt_vf_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
 	}
 }
 
+static int bnxt_vf_rep_setup_tc_block(struct net_device *dev,
+				      struct tc_block_offload *f)
+{
+	struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
+
+	if (f->binder_type != TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
+		return -EOPNOTSUPP;
+
+	switch (f->command) {
+	case TC_BLOCK_BIND:
+		return tcf_block_cb_register(f->block,
+					     bnxt_vf_rep_setup_tc_block_cb,
+					     vf_rep, vf_rep);
+		return 0;
+	case TC_BLOCK_UNBIND:
+		tcf_block_cb_unregister(f->block,
+					bnxt_vf_rep_setup_tc_block_cb, vf_rep);
+		return 0;
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static int bnxt_vf_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
+				void *type_data)
+{
+	switch (type) {
+	case TC_SETUP_CLSFLOWER:
+		return 0; /* will be removed after conversion from ndo */
+	case TC_SETUP_BLOCK:
+		return bnxt_vf_rep_setup_tc_block(dev, type_data);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
 struct net_device *bnxt_get_vf_rep(struct bnxt *bp, u16 cfa_code)
 {
 	u16 vf_idx;
-- 
2.9.5

  parent reply	other threads:[~2017-10-19 13:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 13:50 [patch net-next v2 00/20] net: sched: convert cls ndo_setup_tc offload calls to per-block callbacks Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 01/20] net: sched: add block bind/unbind notif. and extended block_get/put Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 02/20] net: sched: use extended variants of block_get/put in ingress and clsact qdiscs Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 03/20] net: sched: introduce per-block callbacks Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 04/20] net: sched: use tc_setup_cb_call to call " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 05/20] net: sched: cls_matchall: call block callbacks for offload Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 06/20] net: sched: cls_u32: swap u32_remove_hw_knode and u32_remove_hw_hnode Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 07/20] net: sched: cls_u32: call block callbacks for offload Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 08/20] net: sched: cls_bpf: " Jiri Pirko
2017-11-01  0:44   ` Jakub Kicinski
2017-11-01  8:33     ` Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 09/20] mlxsw: spectrum: Convert ndo_setup_tc offloads to block callbacks Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 10/20] mlx5e: " Jiri Pirko
2017-10-19 13:50 ` Jiri Pirko [this message]
2017-10-19 13:50 ` [patch net-next v2 12/20] cxgb4: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 13/20] ixgbe: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 14/20] mlx5e_rep: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 15/20] nfp: flower: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 16/20] nfp: bpf: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 17/20] dsa: " Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 18/20] net: sched: avoid ndo_setup_tc calls for TC_SETUP_CLS* Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 19/20] net: sched: remove unused classid field from tc_cls_common_offload Jiri Pirko
2017-10-19 13:50 ` [patch net-next v2 20/20] net: sched: remove unused is_classid_clsact_ingress/egress helpers Jiri Pirko
2017-10-21  2:04 ` [patch net-next v2 00/20] net: sched: convert cls ndo_setup_tc offload calls to per-block callbacks David Miller
2017-10-24 16:01   ` Alexander Duyck
2017-10-24 16:24     ` Alexander Duyck
     [not found]       ` <CAJ3xEMgdRBEuv0hb_G43zJXXRy=PWgY2tdHuwDN0Opc2NVF35g@mail.gmail.com>
2017-10-24 17:03         ` Or Gerlitz
2017-10-24 17:22         ` Nambiar, Amritha
2017-10-25  8:36       ` Jiri Pirko
2017-10-25 12:15     ` Jiri Pirko
     [not found]       ` <aaa66a3d-766b-f758-692a-eba7f5a8702f@mellanox.com>
2017-10-25 13:42         ` Jiri Pirko
2017-10-25 13:48           ` Or Gerlitz
2017-10-26 20:24       ` Nambiar, Amritha
2017-10-27  7:27         ` Jiri Pirko
2017-10-28  0:52           ` Jakub Kicinski
2017-10-28  7:20             ` Jiri Pirko
2017-10-28  7:53               ` Jakub Kicinski
2017-10-28  8:43                 ` Jiri Pirko
2017-10-28 17:17                   ` Jakub Kicinski
2017-10-29  7:26                     ` Jiri Pirko
2017-10-31 10:46                       ` Jiri Pirko

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=20171019135048.4306-12-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=alexander.h.duyck@intel.com \
    --cc=andrew@lunn.ch \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=ganeshgr@chelsio.com \
    --cc=idosch@mellanox.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jhs@mojatatu.com \
    --cc=john.hurley@netronome.com \
    --cc=leonro@mellanox.com \
    --cc=matanb@mellanox.com \
    --cc=michael.chan@broadcom.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=pieter.jansenvanvuuren@netronome.com \
    --cc=saeedm@mellanox.com \
    --cc=simon.horman@netronome.com \
    --cc=vivien.didelot@savoirfairelinux.com \
    --cc=xiyou.wangcong@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).