From patchwork Mon Jan 21 11:11:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nemanja Marjanovic X-Patchwork-Id: 49982 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 077555A6A; Mon, 21 Jan 2019 12:11:25 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 649114CB5 for ; Mon, 21 Jan 2019 12:11:22 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jan 2019 03:11:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,502,1539673200"; d="scan'208";a="140007592" Received: from silpixa00391954.ir.intel.com (HELO silpixa00391954.ger.corp.intel.com) ([10.237.223.32]) by fmsmga001.fm.intel.com with ESMTP; 21 Jan 2019 03:11:18 -0800 From: Nemanja Marjanovic To: dev@dpdk.org Cc: jasvinder.singh@intel.com, cristian.dumitrescu@intel.com, "Nemanja Marjanovic" Date: Mon, 21 Jan 2019 11:11:21 +0000 Message-Id: <20190121111124.16362-1-nemanja.marjanovic@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190121090210.49103-4-nemanja.marjanovic@intel.com> References: <20190121090210.49103-4-nemanja.marjanovic@intel.com> Subject: [dpdk-dev] [PATCH v6 1/4] pipeline: support QinQ PPPoE encap X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: "Nemanja Marjanovic" Add support of QinQ PPPoE packet encapsulation action. Signed-off-by: Nemanja Marjanovic Acked-by: Cristian Dumitrescu --- v5:Removing footer from patch. v6:Added missing acks. --- lib/librte_pipeline/rte_table_action.c | 61 ++++++++++++++++++++++++++ lib/librte_pipeline/rte_table_action.h | 16 +++++++ 2 files changed, 77 insertions(+) diff --git a/lib/librte_pipeline/rte_table_action.c b/lib/librte_pipeline/rte_table_action.c index 7c7c8dd82..466019934 100644 --- a/lib/librte_pipeline/rte_table_action.c +++ b/lib/librte_pipeline/rte_table_action.c @@ -432,6 +432,7 @@ encap_valid(enum rte_table_action_encap_type encap) case RTE_TABLE_ACTION_ENCAP_MPLS: case RTE_TABLE_ACTION_ENCAP_PPPOE: case RTE_TABLE_ACTION_ENCAP_VXLAN: + case RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE: return 1; default: return 0; @@ -532,6 +533,13 @@ struct encap_vxlan_ipv6_vlan_data { struct vxlan_hdr vxlan; } __attribute__((__packed__)); +struct encap_qinq_pppoe_data { + struct ether_hdr ether; + struct vlan_hdr svlan; + struct vlan_hdr cvlan; + struct pppoe_ppp_hdr pppoe_ppp; +} __attribute__((__packed__)); + static size_t encap_data_size(struct rte_table_action_encap_config *encap) { @@ -563,6 +571,9 @@ encap_data_size(struct rte_table_action_encap_config *encap) else return sizeof(struct encap_vxlan_ipv6_data); + case 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE: + return sizeof(struct encap_qinq_pppoe_data); + default: return 0; } @@ -599,6 +610,9 @@ encap_apply_check(struct rte_table_action_encap_params *p, case RTE_TABLE_ACTION_ENCAP_VXLAN: return 0; + case RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE: + return 0; + default: return -EINVAL; } @@ -676,6 +690,38 @@ encap_qinq_apply(void *data, return 0; } +static int +encap_qinq_pppoe_apply(void *data, + struct rte_table_action_encap_params *p) +{ + struct encap_qinq_pppoe_data *d = data; + + /* Ethernet */ + ether_addr_copy(&p->qinq.ether.da, &d->ether.d_addr); + ether_addr_copy(&p->qinq.ether.sa, &d->ether.s_addr); + d->ether.ether_type = rte_htons(ETHER_TYPE_VLAN); + + /* SVLAN */ + d->svlan.vlan_tci = rte_htons(VLAN(p->qinq.svlan.pcp, + p->qinq.svlan.dei, + p->qinq.svlan.vid)); + d->svlan.eth_proto = rte_htons(ETHER_TYPE_VLAN); + + /* CVLAN */ + d->cvlan.vlan_tci = rte_htons(VLAN(p->qinq.cvlan.pcp, + p->qinq.cvlan.dei, + p->qinq.cvlan.vid)); + d->cvlan.eth_proto = rte_htons(ETHER_TYPE_PPPOE_SESSION); + + /* PPPoE and PPP*/ + d->pppoe_ppp.ver_type_code = rte_htons(0x1100); + d->pppoe_ppp.session_id = rte_htons(p->qinq_pppoe.pppoe.session_id); + d->pppoe_ppp.length = 0; /* not pre-computed */ + d->pppoe_ppp.protocol = rte_htons(PPP_PROTOCOL_IP); + + return 0; +} + static int encap_mpls_apply(void *data, struct rte_table_action_encap_params *p) @@ -921,6 +967,9 @@ encap_apply(void *data, case RTE_TABLE_ACTION_ENCAP_VXLAN: return encap_vxlan_apply(data, p, cfg); + case RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE: + return encap_qinq_pppoe_apply(data, p); + default: return -EINVAL; } @@ -1119,6 +1168,18 @@ pkt_work_encap(struct rte_mbuf *mbuf, break; } + case 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE: + { + struct encap_qinq_pppoe_data *qinq_pppoe = + encap(ip, data, sizeof(struct encap_qinq_pppoe_data)); + qinq_pppoe->pppoe_ppp.length = rte_htons(total_length + 2); + mbuf->data_off = ip_offset - (sizeof(struct rte_mbuf) + + sizeof(struct encap_qinq_pppoe_data)); + mbuf->pkt_len = mbuf->data_len = total_length + + sizeof(struct encap_qinq_pppoe_data); + break; + } + case 1LLU << RTE_TABLE_ACTION_ENCAP_VXLAN: { if (cfg->vxlan.ip_version) diff --git a/lib/librte_pipeline/rte_table_action.h b/lib/librte_pipeline/rte_table_action.h index c96061291..53d16af8a 100644 --- a/lib/librte_pipeline/rte_table_action.h +++ b/lib/librte_pipeline/rte_table_action.h @@ -380,6 +380,9 @@ enum rte_table_action_encap_type { * Ether -> { Ether | VLAN | IP | UDP | VXLAN | Ether } */ RTE_TABLE_ACTION_ENCAP_VXLAN, + + /** IP -> { Ether | S-VLAN | C-VLAN | PPPoE | PPP | IP } */ + RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE, }; /** Pre-computed Ethernet header fields for encapsulation action. */ @@ -529,6 +532,16 @@ struct rte_table_action_encap_config { }; }; +/** QinQ_PPPoE encap paramaeters. */ +struct rte_table_encap_ether_qinq_pppoe { + + /** Only valid when *type* is set to QinQ. */ + struct rte_table_action_ether_hdr ether; + struct rte_table_action_vlan_hdr svlan; /**< Service VLAN header. */ + struct rte_table_action_vlan_hdr cvlan; /**< Customer VLAN header. */ + struct rte_table_action_pppoe_hdr pppoe; /**< PPPoE/PPP headers. */ +}; + /** Encap action parameters (per table rule). */ struct rte_table_action_encap_params { /** Encapsulation type. */ @@ -553,6 +566,9 @@ struct rte_table_action_encap_params { /** Only valid when *type* is set to VXLAN. */ struct rte_table_action_encap_vxlan_params vxlan; + + /** Only valid when *type* is set to QinQ_PPPoE. */ + struct rte_table_encap_ether_qinq_pppoe qinq_pppoe; }; }; From patchwork Mon Jan 21 11:11:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nemanja Marjanovic X-Patchwork-Id: 49981 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 492DB58FA; Mon, 21 Jan 2019 12:11:23 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 99E6A4CB5 for ; Mon, 21 Jan 2019 12:11:21 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jan 2019 03:11:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,502,1539673200"; d="scan'208";a="140007602" Received: from silpixa00391954.ir.intel.com (HELO silpixa00391954.ger.corp.intel.com) ([10.237.223.32]) by fmsmga001.fm.intel.com with ESMTP; 21 Jan 2019 03:11:19 -0800 From: Nemanja Marjanovic To: dev@dpdk.org Cc: jasvinder.singh@intel.com, cristian.dumitrescu@intel.com, "Nemanja Marjanovic" Date: Mon, 21 Jan 2019 11:11:22 +0000 Message-Id: <20190121111124.16362-2-nemanja.marjanovic@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190121111124.16362-1-nemanja.marjanovic@intel.com> References: <20190121090210.49103-4-nemanja.marjanovic@intel.com> <20190121111124.16362-1-nemanja.marjanovic@intel.com> Subject: [dpdk-dev] [PATCH v6 2/4] examples/ip_pipeline: support QinQ PPPoE encap X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: "Nemanja Marjanovic" Add implementation of QinQ PPPoE packet encapsulation action. Signed-off-by: Nemanja Marjanovic Acked-by: Cristian Dumitrescu --- v5:Removing footer from patch. v6:Added missing acks. --- examples/ip_pipeline/cli.c | 46 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index 910386282..dd05393ef 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -1022,7 +1022,7 @@ static const char cmd_table_action_profile_help[] = " tc \n" " stats none | pkts | bytes | both]\n" " [tm spp pps ]\n" -" [encap ether | vlan | qinq | mpls | pppoe |\n" +" [encap ether | vlan | qinq | mpls | pppoe | qinq_pppoe \n" " vxlan offset ipv4 | ipv6 vlan on | off]\n" " [nat src | dst\n" " proto udp | tcp]\n" @@ -1290,7 +1290,10 @@ cmd_table_action_profile(char **tokens, p.encap.encap_mask = 1LLU << RTE_TABLE_ACTION_ENCAP_VXLAN; n_extra_tokens = 5; - } else { + } else if (strcmp(tokens[t0 + 1], "qinq_pppoe") == 0) + p.encap.encap_mask = + 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE; + else { snprintf(out, out_size, MSG_ARG_MISMATCH, "encap"); return; } @@ -3090,6 +3093,7 @@ parse_match(char **tokens, * ether * | vlan * | qinq + * | qinq_pppoe * | mpls unicast | multicast * * label0