From patchwork Tue Jul 23 14:33:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 1135723 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="yJLNB0Hg"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45tLbt4Tllz9s7T for ; Wed, 24 Jul 2019 00:35:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390443AbfGWOfF (ORCPT ); Tue, 23 Jul 2019 10:35:05 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33803 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732631AbfGWOfE (ORCPT ); Tue, 23 Jul 2019 10:35:04 -0400 Received: by mail-wr1-f68.google.com with SMTP id 31so43493788wrm.1 for ; Tue, 23 Jul 2019 07:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pq7ZqhgMhmTZxHcB33wL+SDq5biZ2pX/Ow9vHAYJNGg=; b=yJLNB0HgnzBD3fZ+HkCZsi1fzKSPpnAQ9SSxhcDcRnNv/nFeltsfdoXUIm68wBc8c8 8OGMH2FOAtV7jwE+yZD6OdzAB0oUcLaXTGOn5MzF66x3qv9XzjhPOgKUEx6Rj9QU6NBk Pz095c/KdFqiQM28AdsZu2odJWZkahTHdgV0DNedq1/6eefwOkTyuEjH7T1R/pAfz8kI F0VotaNX0pvp/XNlH/G+Vp2yEAzXByF8E0jWA+nVFm0jvMhMZc3XjPJot315VN/U7m/m aNdznUA5ddNYKvAPi3uaSAf8NPJh2QaotUT6ckLbaWE6d4MPJHFX5kKqgaqTeUBcn9Ot az8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pq7ZqhgMhmTZxHcB33wL+SDq5biZ2pX/Ow9vHAYJNGg=; b=tVVn2mJ5lY/EBHHmAy2InCVSOxV52aRv+w0ygZYtu8zyMc+BTTOZYB+fYM0IQdkGRb zZZSxdP6BiNUc8zXIdmuHpPfkyMR8N75Re1UkKPVC8hoQCNtU6u5fY3onhQJbwPLaI+W x6g1dcoA0WYYjHAN2lwc1/ARJL5+k9qR6t7vM6kuWywKokLdvlH7Rc6VrG8sek0pwco7 wZH41+GAcYCNLvUF2AwfsgagMhNAVCqNfQCnC6P5qJKY1xpy78hqKoSVFJdt3cBE6zjB eAoGaOwSOTHwzY05QcbQOmsZDNtXV8yUea00NrXe8CEt52j27XXdzmUpqEavo7S4GNwi 0Zzw== X-Gm-Message-State: APjAAAWnMQSVKhjRby+Dyw5NYANjscMD7IaCXRLnf18K4WV6kMFHUC43 r5pNiv7N/UkVjuRrXiXda1pMxOZpL20= X-Google-Smtp-Source: APXvYqzngBrTcaOcs9vBxycTsQ4I8VYoetN3Ri80WdCUBVgTlsGmuuwF+6z4VxVIvCnNG0VS1HrU6A== X-Received: by 2002:a5d:4941:: with SMTP id r1mr78478624wrs.225.1563892501869; Tue, 23 Jul 2019 07:35:01 -0700 (PDT) Received: from jhurley-Precision-Tower-3420.netronome.com ([80.76.204.157]) by smtp.gmail.com with ESMTPSA id l9sm36710165wmh.36.2019.07.23.07.35.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jul 2019 07:35:01 -0700 (PDT) From: John Hurley To: netdev@vger.kernel.org Cc: davem@davemloft.net, simon.horman@netronome.com, jakub.kicinski@netronome.com, oss-drivers@netronome.com, John Hurley Subject: [PATCH net-next 1/4] net: sched: include mpls actions in hardware intermediate representation Date: Tue, 23 Jul 2019 15:33:59 +0100 Message-Id: <1563892442-4654-2-git-send-email-john.hurley@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1563892442-4654-1-git-send-email-john.hurley@netronome.com> References: <1563892442-4654-1-git-send-email-john.hurley@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org A recent addition to TC actions is the ability to manipulate the MPLS headers on packets. In preparation to offload such actions to hardware, update the IR code to accept and prepare the new actions. Note that no driver currently impliments the MPLS dec_ttl action so this is not included. Signed-off-by: John Hurley Reviewed-by: Jakub Kicinski --- include/net/flow_offload.h | 19 +++++++++++ include/net/tc_act/tc_mpls.h | 75 ++++++++++++++++++++++++++++++++++++++++++++ net/sched/cls_api.c | 25 +++++++++++++++ 3 files changed, 119 insertions(+) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index b16d216..00b9aab 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -131,6 +131,9 @@ enum flow_action_id { FLOW_ACTION_SAMPLE, FLOW_ACTION_POLICE, FLOW_ACTION_CT, + FLOW_ACTION_MPLS_PUSH, + FLOW_ACTION_MPLS_POP, + FLOW_ACTION_MPLS_MANGLE, }; /* This is mirroring enum pedit_header_type definition for easy mapping between @@ -184,6 +187,22 @@ struct flow_action_entry { int action; u16 zone; } ct; + struct { /* FLOW_ACTION_MPLS_PUSH */ + u32 label; + __be16 proto; + u8 tc; + u8 bos; + u8 ttl; + } mpls_push; + struct { /* FLOW_ACTION_MPLS_POP */ + __be16 proto; + } mpls_pop; + struct { /* FLOW_ACTION_MPLS_MANGLE */ + u32 label; + u8 tc; + u8 bos; + u8 ttl; + } mpls_mangle; }; }; diff --git a/include/net/tc_act/tc_mpls.h b/include/net/tc_act/tc_mpls.h index 4bc3d92..721de4f 100644 --- a/include/net/tc_act/tc_mpls.h +++ b/include/net/tc_act/tc_mpls.h @@ -27,4 +27,79 @@ struct tcf_mpls { }; #define to_mpls(a) ((struct tcf_mpls *)a) +static inline bool is_tcf_mpls(const struct tc_action *a) +{ +#ifdef CONFIG_NET_CLS_ACT + if (a->ops && a->ops->id == TCA_ID_MPLS) + return true; +#endif + return false; +} + +static inline u32 tcf_mpls_action(const struct tc_action *a) +{ + u32 tcfm_action; + + rcu_read_lock(); + tcfm_action = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_action; + rcu_read_unlock(); + + return tcfm_action; +} + +static inline __be16 tcf_mpls_proto(const struct tc_action *a) +{ + __be16 tcfm_proto; + + rcu_read_lock(); + tcfm_proto = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_proto; + rcu_read_unlock(); + + return tcfm_proto; +} + +static inline u32 tcf_mpls_label(const struct tc_action *a) +{ + u32 tcfm_label; + + rcu_read_lock(); + tcfm_label = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_label; + rcu_read_unlock(); + + return tcfm_label; +} + +static inline u8 tcf_mpls_tc(const struct tc_action *a) +{ + u8 tcfm_tc; + + rcu_read_lock(); + tcfm_tc = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_tc; + rcu_read_unlock(); + + return tcfm_tc; +} + +static inline u8 tcf_mpls_bos(const struct tc_action *a) +{ + u8 tcfm_bos; + + rcu_read_lock(); + tcfm_bos = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_bos; + rcu_read_unlock(); + + return tcfm_bos; +} + +static inline u8 tcf_mpls_ttl(const struct tc_action *a) +{ + u8 tcfm_ttl; + + rcu_read_lock(); + tcfm_ttl = rcu_dereference(to_mpls(a)->mpls_p)->tcfm_ttl; + rcu_read_unlock(); + + return tcfm_ttl; +} + #endif /* __NET_TC_MPLS_H */ diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index efd3cfb..3565d9a 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -36,6 +36,7 @@ #include #include #include +#include extern const struct nla_policy rtm_tca_policy[TCA_MAX + 1]; @@ -3269,6 +3270,30 @@ int tc_setup_flow_action(struct flow_action *flow_action, entry->id = FLOW_ACTION_CT; entry->ct.action = tcf_ct_action(act); entry->ct.zone = tcf_ct_zone(act); + } else if (is_tcf_mpls(act)) { + switch (tcf_mpls_action(act)) { + case TCA_MPLS_ACT_PUSH: + entry->id = FLOW_ACTION_MPLS_PUSH; + entry->mpls_push.proto = tcf_mpls_proto(act); + entry->mpls_push.label = tcf_mpls_label(act); + entry->mpls_push.tc = tcf_mpls_tc(act); + entry->mpls_push.bos = tcf_mpls_bos(act); + entry->mpls_push.ttl = tcf_mpls_ttl(act); + break; + case TCA_MPLS_ACT_POP: + entry->id = FLOW_ACTION_MPLS_POP; + entry->mpls_pop.proto = tcf_mpls_proto(act); + break; + case TCA_MPLS_ACT_MODIFY: + entry->id = FLOW_ACTION_MPLS_MANGLE; + entry->mpls_mangle.label = tcf_mpls_label(act); + entry->mpls_mangle.tc = tcf_mpls_tc(act); + entry->mpls_mangle.bos = tcf_mpls_bos(act); + entry->mpls_mangle.ttl = tcf_mpls_ttl(act); + break; + default: + goto err_out; + } } else { goto err_out; } From patchwork Tue Jul 23 14:34:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 1135724 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="McePMHBQ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45tLby2lnFz9s7T for ; Wed, 24 Jul 2019 00:35:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390480AbfGWOfI (ORCPT ); Tue, 23 Jul 2019 10:35:08 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:36497 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730148AbfGWOfG (ORCPT ); Tue, 23 Jul 2019 10:35:06 -0400 Received: by mail-wm1-f65.google.com with SMTP id g67so34615770wme.1 for ; Tue, 23 Jul 2019 07:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E3jBQ4NlDdbnWjjTmtwjy5FPOIM/RN9NgYNytZIZbQg=; b=McePMHBQvT0MutwLTRqaI33TKbwZG6fjAWmMdsGTtuxRFPP4AzYHMI5OdVJPvYaMgm sjTBFIt/mqBTwMeDWtxHvmDocm72YuJETjG0aXVkA3f+yehaeMzaLc4WllKHwRv26uEM D0oMK2nHwBUQ+/qcYw+5/U3yLoe1hhmv8DN5q1NOK5iWKmfPd/3LjqTzj+qoPRQt9qX/ PRVohLR0CRatpw2JmrnHV6Bvw2ql4Bgo7a+Ude/AhVaOQ316Rj8GR7BMZi1QAjctGYwi 26oRaDANxcE/oBcJy2Xxuk+WTGzgVko4tNd3GY2VDRSSR9ZOvKXLGeZCjpvSVNE5g8zQ 0BUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=E3jBQ4NlDdbnWjjTmtwjy5FPOIM/RN9NgYNytZIZbQg=; b=qmhfDokSB5D6hyj6QuZIAN0sVmb2Cc9krPh/LBoJ6LUCVxmc1w1bo+ZfEGbFZJiLAq IKoTXqiKIYjFZb0vU9/YHJpGbf1WQ8YP/9+/Kyeu42Am2nwprJ7cf6bJb46mqhy0WbIP qsxvRFutuMO4zMYjDSkq3LL4OkpEuqMAjAKNCVZIX3EkNhlcYy91Dj5EGq0iI83ygcR8 ibTGURefhqHBorlzVwHvUqB8PpyWtlofNR3ccefT0/f76kyhuqXgbz5Uh5YNVG04uNFH BOeZAI/C90wt9jRCecXXY4Dv8KRkTZmi/xouP1ymuKZ4NwAGm6qBPDGY2gLMZq8hm5xP iCBg== X-Gm-Message-State: APjAAAXVsa47zWyrCTlJL21nfyzfBVfaaibCV+ENulVb5LXiV6skYaLo 2wAVCfuZSa/9crIr+8WIz+6aBuA0tKE= X-Google-Smtp-Source: APXvYqxvdO6Tvgo0R7B07DPqWflz85DptSW8d50xJRnIa7P0xc7s7gNCQLbbObNtEDs8y/UIpWlr4w== X-Received: by 2002:a1c:4184:: with SMTP id o126mr67657099wma.68.1563892502961; Tue, 23 Jul 2019 07:35:02 -0700 (PDT) Received: from jhurley-Precision-Tower-3420.netronome.com ([80.76.204.157]) by smtp.gmail.com with ESMTPSA id l9sm36710165wmh.36.2019.07.23.07.35.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jul 2019 07:35:02 -0700 (PDT) From: John Hurley To: netdev@vger.kernel.org Cc: davem@davemloft.net, simon.horman@netronome.com, jakub.kicinski@netronome.com, oss-drivers@netronome.com, John Hurley Subject: [PATCH net-next 2/4] nfp: flower: offload MPLS push action Date: Tue, 23 Jul 2019 15:34:00 +0100 Message-Id: <1563892442-4654-3-git-send-email-john.hurley@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1563892442-4654-1-git-send-email-john.hurley@netronome.com> References: <1563892442-4654-1-git-send-email-john.hurley@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Recent additions to the kernel include a TC action module to manipulate MPLS headers on packets. Such actions are available to offload via the flow_offload intermediate representation API. Modify the NFP driver to allow the offload of MPLS push actions to firmware. Signed-off-by: John Hurley Reviewed-by: Simon Horman Reviewed-by: Jakub Kicinski --- drivers/net/ethernet/netronome/nfp/flower/action.c | 50 ++++++++++++++++++++++ drivers/net/ethernet/netronome/nfp/flower/cmsg.h | 7 +++ 2 files changed, 57 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index 5a54fe8..9e18bec 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c @@ -2,10 +2,12 @@ /* Copyright (C) 2017-2018 Netronome Systems, Inc. */ #include +#include #include #include #include #include +#include #include #include #include @@ -25,6 +27,38 @@ NFP_FL_TUNNEL_KEY | \ NFP_FL_TUNNEL_GENEVE_OPT) +static int +nfp_fl_push_mpls(struct nfp_fl_push_mpls *push_mpls, + const struct flow_action_entry *act, + struct netlink_ext_ack *extack) +{ + size_t act_size = sizeof(struct nfp_fl_push_mpls); + u32 mpls_lse = 0; + + push_mpls->head.jump_id = NFP_FL_ACTION_OPCODE_PUSH_MPLS; + push_mpls->head.len_lw = act_size >> NFP_FL_LW_SIZ; + + /* BOS is optional in the TC action but required for offload. */ + if (act->mpls_push.bos != ACT_MPLS_BOS_NOT_SET) { + mpls_lse |= act->mpls_push.bos << MPLS_LS_S_SHIFT; + } else { + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: BOS field must explicitly be set for MPLS push"); + return -EOPNOTSUPP; + } + + /* Leave MPLS TC as a default value of 0 if not explicitly set. */ + if (act->mpls_push.tc != ACT_MPLS_TC_NOT_SET) + mpls_lse |= act->mpls_push.tc << MPLS_LS_TC_SHIFT; + + /* Proto, label and TTL are enforced and verified for MPLS push. */ + mpls_lse |= act->mpls_push.label << MPLS_LS_LABEL_SHIFT; + mpls_lse |= act->mpls_push.ttl << MPLS_LS_TTL_SHIFT; + push_mpls->ethtype = act->mpls_push.proto; + push_mpls->lse = cpu_to_be32(mpls_lse); + + return 0; +} + static void nfp_fl_pop_vlan(struct nfp_fl_pop_vlan *pop_vlan) { size_t act_size = sizeof(struct nfp_fl_pop_vlan); @@ -869,6 +903,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, struct nfp_fl_set_ipv4_tun *set_tun; struct nfp_fl_pre_tunnel *pre_tun; struct nfp_fl_push_vlan *psh_v; + struct nfp_fl_push_mpls *psh_m; struct nfp_fl_pop_vlan *pop_v; int err; @@ -975,6 +1010,21 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, */ *csum_updated &= ~act->csum_flags; break; + case FLOW_ACTION_MPLS_PUSH: + if (*a_len + + sizeof(struct nfp_fl_push_mpls) > NFP_FL_MAX_A_SIZ) { + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: maximum allowed action list size exceeded at push MPLS"); + return -EOPNOTSUPP; + } + + psh_m = (struct nfp_fl_push_mpls *)&nfp_fl->action_data[*a_len]; + nfp_fl->meta.shortcut = cpu_to_be32(NFP_FL_SC_ACT_NULL); + + err = nfp_fl_push_mpls(psh_m, act, extack); + if (err) + return err; + *a_len += sizeof(struct nfp_fl_push_mpls); + break; default: /* Currently we do not handle any other actions. */ NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported action in action list"); diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h index 0f1706a..91af0fa 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h @@ -68,6 +68,7 @@ #define NFP_FL_ACTION_OPCODE_OUTPUT 0 #define NFP_FL_ACTION_OPCODE_PUSH_VLAN 1 #define NFP_FL_ACTION_OPCODE_POP_VLAN 2 +#define NFP_FL_ACTION_OPCODE_PUSH_MPLS 3 #define NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL 6 #define NFP_FL_ACTION_OPCODE_SET_ETHERNET 7 #define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9 @@ -232,6 +233,12 @@ struct nfp_fl_push_geneve { u8 opt_data[]; }; +struct nfp_fl_push_mpls { + struct nfp_fl_act_head head; + __be16 ethtype; + __be32 lse; +}; + /* Metadata with L2 (1W/4B) * ---------------------------------------------------------------- * 3 2 1 From patchwork Tue Jul 23 14:34:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 1135725 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="LPjq/wnd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45tLbz1XtRz9sDB for ; Wed, 24 Jul 2019 00:35:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390506AbfGWOfJ (ORCPT ); Tue, 23 Jul 2019 10:35:09 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33461 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388162AbfGWOfG (ORCPT ); Tue, 23 Jul 2019 10:35:06 -0400 Received: by mail-wm1-f65.google.com with SMTP id h19so31267615wme.0 for ; Tue, 23 Jul 2019 07:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LXHhPPIjP7sfMTSBJF6HAGk2blGA2hiq+lqeIVYPAVE=; b=LPjq/wndhUpuFfSTF6NGPf7cGwhZsx/Cn3Boxc6xd1iAsNC9hw+697iO6jXXJk6yUw ZBOXEWx/rWdmj9Ev9Hyp7cc+ORHxGzXN1i3/m1OWQqcn/CsWuFKaQQQiTY2jSLxhpauk 63mg3328UWNj2yvr4hSYHjMSkoLNBGvXW58h9nqFMVz5Vvowhg8YHwX7YnC22JjBwGa7 mmzOl+e+7NTl93slVhC5aQF+HAVd/0ihyp/wNIU+lYZsyeprLHHIqArCXUm30wz3Ndvq Q9VWgOYT6iTQO54SDkNQ68zdIcV9rdnNExyI9qu4c5m9NLssjeQF2ORC2voQt1kZy/0d TP+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LXHhPPIjP7sfMTSBJF6HAGk2blGA2hiq+lqeIVYPAVE=; b=iE+uH9NuDILB6rbTdbYYX5kgWJNIsC94R62PtzaZ5+o4AjfaFajtruDv00wOdVV5wt bJx90bzDA5W0q2qxk18WhsgNNHqcKCpy+VMyGdg054bGxglci/u7bJnqGF0t53tfoFmE 6jDHdyy60ARtCi8+i44pvWHUqkr4OjD5ZDvPhbFXQ5aK12vZYD+nTnXFswjiPIhXx10P Smy5tKs40uxrAqYc0HrS3nk+0hDdbQjy4zwdIsz6YzrEF3QIbGo2WzxAfyQDXdNs1ABQ Z/Nsy/kgDwawgV3oF7aUnwnbCKDjFEsBznlF8Kb8XvP/BT4c9mZ/gK+cwDhm5D97pLEG zlUw== X-Gm-Message-State: APjAAAXzC8VA5LMyaO7TnZ7jlwOGIsBRzMz/nw+vUumLp+81g3MsWHGu lwW74k9A14gW97acUOvlGNiLV2pCoq0= X-Google-Smtp-Source: APXvYqwBXH0qpQrpMoXVfSP8ICFiAUFYIrIyzqlR7JvI/+tDxzLudL0byip5K0EktLsSooPb0ydK7w== X-Received: by 2002:a1c:2c41:: with SMTP id s62mr69484658wms.8.1563892503927; Tue, 23 Jul 2019 07:35:03 -0700 (PDT) Received: from jhurley-Precision-Tower-3420.netronome.com ([80.76.204.157]) by smtp.gmail.com with ESMTPSA id l9sm36710165wmh.36.2019.07.23.07.35.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jul 2019 07:35:03 -0700 (PDT) From: John Hurley To: netdev@vger.kernel.org Cc: davem@davemloft.net, simon.horman@netronome.com, jakub.kicinski@netronome.com, oss-drivers@netronome.com, John Hurley Subject: [PATCH net-next 3/4] nfp: flower: offload MPLS pop action Date: Tue, 23 Jul 2019 15:34:01 +0100 Message-Id: <1563892442-4654-4-git-send-email-john.hurley@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1563892442-4654-1-git-send-email-john.hurley@netronome.com> References: <1563892442-4654-1-git-send-email-john.hurley@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Recent additions to the kernel include a TC action module to manipulate MPLS headers on packets. Such actions are available to offload via the flow_offload intermediate representation API. Modify the NFP driver to allow the offload of MPLS pop actions to firmware. The act_mpls TC module enforces that the next protocol is supplied along with the pop action. Passing this to firmware allows it to properly rebuild the underlying packet after the pop. Signed-off-by: John Hurley Reviewed-by: Simon Horman Reviewed-by: Jakub Kicinski --- drivers/net/ethernet/netronome/nfp/flower/action.c | 25 ++++++++++++++++++++++ drivers/net/ethernet/netronome/nfp/flower/cmsg.h | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index 9e18bec..7f288ae 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c @@ -59,6 +59,17 @@ nfp_fl_push_mpls(struct nfp_fl_push_mpls *push_mpls, return 0; } +static void +nfp_fl_pop_mpls(struct nfp_fl_pop_mpls *pop_mpls, + const struct flow_action_entry *act) +{ + size_t act_size = sizeof(struct nfp_fl_pop_mpls); + + pop_mpls->head.jump_id = NFP_FL_ACTION_OPCODE_POP_MPLS; + pop_mpls->head.len_lw = act_size >> NFP_FL_LW_SIZ; + pop_mpls->ethtype = act->mpls_pop.proto; +} + static void nfp_fl_pop_vlan(struct nfp_fl_pop_vlan *pop_vlan) { size_t act_size = sizeof(struct nfp_fl_pop_vlan); @@ -905,6 +916,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, struct nfp_fl_push_vlan *psh_v; struct nfp_fl_push_mpls *psh_m; struct nfp_fl_pop_vlan *pop_v; + struct nfp_fl_pop_mpls *pop_m; int err; switch (act->id) { @@ -1025,6 +1037,19 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, return err; *a_len += sizeof(struct nfp_fl_push_mpls); break; + case FLOW_ACTION_MPLS_POP: + if (*a_len + + sizeof(struct nfp_fl_pop_mpls) > NFP_FL_MAX_A_SIZ) { + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: maximum allowed action list size exceeded at pop MPLS"); + return -EOPNOTSUPP; + } + + pop_m = (struct nfp_fl_pop_mpls *)&nfp_fl->action_data[*a_len]; + nfp_fl->meta.shortcut = cpu_to_be32(NFP_FL_SC_ACT_NULL); + + nfp_fl_pop_mpls(pop_m, act); + *a_len += sizeof(struct nfp_fl_pop_mpls); + break; default: /* Currently we do not handle any other actions. */ NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported action in action list"); diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h index 91af0fa..3198ad4 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h @@ -69,6 +69,7 @@ #define NFP_FL_ACTION_OPCODE_PUSH_VLAN 1 #define NFP_FL_ACTION_OPCODE_POP_VLAN 2 #define NFP_FL_ACTION_OPCODE_PUSH_MPLS 3 +#define NFP_FL_ACTION_OPCODE_POP_MPLS 4 #define NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL 6 #define NFP_FL_ACTION_OPCODE_SET_ETHERNET 7 #define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9 @@ -239,6 +240,11 @@ struct nfp_fl_push_mpls { __be32 lse; }; +struct nfp_fl_pop_mpls { + struct nfp_fl_act_head head; + __be16 ethtype; +}; + /* Metadata with L2 (1W/4B) * ---------------------------------------------------------------- * 3 2 1 From patchwork Tue Jul 23 14:34:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 1135726 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="ArNAEbSF"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45tLc11dK1z9s3l for ; Wed, 24 Jul 2019 00:35:13 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390531AbfGWOfM (ORCPT ); Tue, 23 Jul 2019 10:35:12 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:33463 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732631AbfGWOfI (ORCPT ); Tue, 23 Jul 2019 10:35:08 -0400 Received: by mail-wm1-f67.google.com with SMTP id h19so31267662wme.0 for ; Tue, 23 Jul 2019 07:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aNEFEm5cpefDO7sZH5Svg2UubPCFTmU+ct79w97ss2I=; b=ArNAEbSFh1MhPP0oCPC3zIC6lYZ0GOs/HyfjMYRtyhI6bKyvCKnrqMR+2pEBKnROo+ 8g7CggeWHAIHT19xgI2UHeQlP5Ml7uzS+Lavrys2kQxWlgnIkCgPZJfcdghX905n4EA/ /4QxtCwjYZ7dLuaWU///ocGpxx3VaBI9kInk8RL26yyyAHcPbgfzea6utQUMdl33c6hd l/bFZT/mKNVF33Ip+/eMHTiyLXWdMFkBYNadSrvL9mKEki7B0eAlEJ+fGSRhgWPBa/ND R/guuz5vd/CwUr1R8sgFuzCtC9TNw8Avmwy3RySP11Q6JO8WZpSIXpK6kzqK7BZCLrIJ fuLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aNEFEm5cpefDO7sZH5Svg2UubPCFTmU+ct79w97ss2I=; b=AyJ3Vu2H9sdH3W+Hz6Twoi8BDs2N7hsl2Ywkc+B3TIKl42fhQg0AL1UeD9sOTd9Yvs EBparZOYCp8HpHbDiksQzoH9Hu4YKUe95/Fja5x/liDii0TXgf6yMle4lsENaQkmpbXN OHwT6S6ft5DiAF6UuXN+6hIphpIECuuZgxjf4rPdWx1EtBtcNIJ5cvuqEEY5F9JqurZ2 F6xQ2qUE8wvAsa9MulHREvN6vWjYEj7QxkKcGzLm0eBSFxcqZUmOIbOoedYSoXy4LEZS yEzmUbCoKXJ2/Ub0/8Am01nD3yJoaPGkrjQD6vYMqPjF7mPOy09+wftHOKHu6i0/wqpP tqig== X-Gm-Message-State: APjAAAWbA5IKONFoOvwOk7mzCp0uT/2zfvhvc9im5q5yFn3BHI1Yp5ZR vEXiEgcaLmif+eFYpoFObDNLsaPNajc= X-Google-Smtp-Source: APXvYqw6ph2seCGXRLE6KIjAg0D6AJo91Gi86B2OPzGa8VXL3wJSoolCrUTLjb4cfgERvdfMnL2KlA== X-Received: by 2002:a1c:a848:: with SMTP id r69mr67582829wme.12.1563892504972; Tue, 23 Jul 2019 07:35:04 -0700 (PDT) Received: from jhurley-Precision-Tower-3420.netronome.com ([80.76.204.157]) by smtp.gmail.com with ESMTPSA id l9sm36710165wmh.36.2019.07.23.07.35.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jul 2019 07:35:04 -0700 (PDT) From: John Hurley To: netdev@vger.kernel.org Cc: davem@davemloft.net, simon.horman@netronome.com, jakub.kicinski@netronome.com, oss-drivers@netronome.com, John Hurley Subject: [PATCH net-next 4/4] nfp: flower: offload MPLS set action Date: Tue, 23 Jul 2019 15:34:02 +0100 Message-Id: <1563892442-4654-5-git-send-email-john.hurley@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1563892442-4654-1-git-send-email-john.hurley@netronome.com> References: <1563892442-4654-1-git-send-email-john.hurley@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Recent additions to the kernel include a TC action module to manipulate MPLS headers on packets. Such actions are available to offload via the flow_offload intermediate representation API. Modify the NFP driver to allow the offload of MPLS set actions to firmware. Set actions update the outermost MPLS header. The offload includes a mask to specify which fields should be set. Signed-off-by: John Hurley Reviewed-by: Simon Horman Reviewed-by: Jakub Kicinski --- drivers/net/ethernet/netronome/nfp/flower/action.c | 45 ++++++++++++++++++++++ drivers/net/ethernet/netronome/nfp/flower/cmsg.h | 8 ++++ 2 files changed, 53 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index 7f288ae..ff2f419 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c @@ -70,6 +70,37 @@ nfp_fl_pop_mpls(struct nfp_fl_pop_mpls *pop_mpls, pop_mpls->ethtype = act->mpls_pop.proto; } +static void +nfp_fl_set_mpls(struct nfp_fl_set_mpls *set_mpls, + const struct flow_action_entry *act) +{ + size_t act_size = sizeof(struct nfp_fl_set_mpls); + u32 mpls_lse = 0, mpls_mask = 0; + + set_mpls->head.jump_id = NFP_FL_ACTION_OPCODE_SET_MPLS; + set_mpls->head.len_lw = act_size >> NFP_FL_LW_SIZ; + + if (act->mpls_mangle.label != ACT_MPLS_LABEL_NOT_SET) { + mpls_lse |= act->mpls_mangle.label << MPLS_LS_LABEL_SHIFT; + mpls_mask |= MPLS_LS_LABEL_MASK; + } + if (act->mpls_mangle.tc != ACT_MPLS_TC_NOT_SET) { + mpls_lse |= act->mpls_mangle.tc << MPLS_LS_TC_SHIFT; + mpls_mask |= MPLS_LS_TC_MASK; + } + if (act->mpls_mangle.bos != ACT_MPLS_BOS_NOT_SET) { + mpls_lse |= act->mpls_mangle.bos << MPLS_LS_S_SHIFT; + mpls_mask |= MPLS_LS_S_MASK; + } + if (act->mpls_mangle.ttl) { + mpls_lse |= act->mpls_mangle.ttl << MPLS_LS_TTL_SHIFT; + mpls_mask |= MPLS_LS_TTL_MASK; + } + + set_mpls->lse = cpu_to_be32(mpls_lse); + set_mpls->lse_mask = cpu_to_be32(mpls_mask); +} + static void nfp_fl_pop_vlan(struct nfp_fl_pop_vlan *pop_vlan) { size_t act_size = sizeof(struct nfp_fl_pop_vlan); @@ -917,6 +948,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, struct nfp_fl_push_mpls *psh_m; struct nfp_fl_pop_vlan *pop_v; struct nfp_fl_pop_mpls *pop_m; + struct nfp_fl_set_mpls *set_m; int err; switch (act->id) { @@ -1050,6 +1082,19 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, nfp_fl_pop_mpls(pop_m, act); *a_len += sizeof(struct nfp_fl_pop_mpls); break; + case FLOW_ACTION_MPLS_MANGLE: + if (*a_len + + sizeof(struct nfp_fl_set_mpls) > NFP_FL_MAX_A_SIZ) { + NL_SET_ERR_MSG_MOD(extack, "unsupported offload: maximum allowed action list size exceeded at set MPLS"); + return -EOPNOTSUPP; + } + + set_m = (struct nfp_fl_set_mpls *)&nfp_fl->action_data[*a_len]; + nfp_fl->meta.shortcut = cpu_to_be32(NFP_FL_SC_ACT_NULL); + + nfp_fl_set_mpls(set_m, act); + *a_len += sizeof(struct nfp_fl_set_mpls); + break; default: /* Currently we do not handle any other actions. */ NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported action in action list"); diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h index 3198ad4..3324394 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.h +++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.h @@ -72,6 +72,7 @@ #define NFP_FL_ACTION_OPCODE_POP_MPLS 4 #define NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL 6 #define NFP_FL_ACTION_OPCODE_SET_ETHERNET 7 +#define NFP_FL_ACTION_OPCODE_SET_MPLS 8 #define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9 #define NFP_FL_ACTION_OPCODE_SET_IPV4_TTL_TOS 10 #define NFP_FL_ACTION_OPCODE_SET_IPV6_SRC 11 @@ -245,6 +246,13 @@ struct nfp_fl_pop_mpls { __be16 ethtype; }; +struct nfp_fl_set_mpls { + struct nfp_fl_act_head head; + __be16 reserved; + __be32 lse_mask; + __be32 lse; +}; + /* Metadata with L2 (1W/4B) * ---------------------------------------------------------------- * 3 2 1