From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C4EE41B396 for ; Mon, 14 Jan 2019 11:46:37 +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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2019 02:46:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,477,1539673200"; d="scan'208";a="138057996" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by fmsmga001.fm.intel.com with ESMTP; 14 Jan 2019 02:46:36 -0800 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.205]) by irsmsx110.ger.corp.intel.com ([169.254.15.16]) with mapi id 14.03.0415.000; Mon, 14 Jan 2019 10:46:34 +0000 From: "Dumitrescu, Cristian" To: "Marjanovic, Nemanja" , "dev@dpdk.org" CC: "Singh, Jasvinder" Thread-Topic: [PATCH v2] ip_pipeline: add QinQ PPPoE encapsulation action Thread-Index: AQHUq/Mqbv6HpdIC30eTMq1NBhC8kaWukfDg Date: Mon, 14 Jan 2019 10:46:33 +0000 Message-ID: <3EB4FA525960D640B5BDFFD6A3D891268E829D34@IRSMSX108.ger.corp.intel.com> References: <20190114100259.23822-1-nemanja.marjanovic@intel.com> <20190114102310.25596-1-nemanja.marjanovic@intel.com> In-Reply-To: <20190114102310.25596-1-nemanja.marjanovic@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWRjOTNjMTEtZDI3ZC00YjRlLTg5OWUtNDFkY2YxMzNmYWZhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVzdZNVwvNFlVSUF4VlRLSU10UjdNZnlPeHFWSzVZXC9xVlVuVVRXREdJUDRmUno0MmFNR0FFNFNOSFN4VlN6bnZuIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] ip_pipeline: add QinQ PPPoE encapsulation action 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: , X-List-Received-Date: Mon, 14 Jan 2019 10:46:38 -0000 Hi Nemanja, > -----Original Message----- > From: Marjanovic, Nemanja > Sent: Monday, January 14, 2019 10:23 AM > To: dev@dpdk.org > Cc: Singh, Jasvinder ; Dumitrescu, Cristian > ; Marjanovic, Nemanja > > Subject: [PATCH v2] ip_pipeline: add QinQ PPPoE encapsulation action >=20 > Add implementation of QinQ PPPoE packet encapsulation action. >=20 > Signed-off-by: Nemanja Marjanovic > --- > v2:Fix changes from check patch > --- > examples/ip_pipeline/cli.c | 43 +++++++++++++++++- > lib/librte_net/rte_ether.h | 1 + > lib/librte_pipeline/rte_table_action.c | 61 ++++++++++++++++++++++++++ > lib/librte_pipeline/rte_table_action.h | 16 +++++++ > 4 files changed, 119 insertions(+), 2 deletions(-) >=20 > diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c > index 910386282..dcc98ee65 100644 > --- a/examples/ip_pipeline/cli.c > +++ b/examples/ip_pipeline/cli.c We need to add support for this new packet encapsulation in the Soft NIC CL= I, we don't want it to get out of sync with IP pipeline. Basically, add essentially the same CLI code in drivers/net/softnic/rte_eth= _softnic_cli.c, can you please do this? > @@ -1290,11 +1290,13 @@ cmd_table_action_profile(char **tokens, >=20 > p.encap.encap_mask =3D 1LLU << > RTE_TABLE_ACTION_ENCAP_VXLAN; > n_extra_tokens =3D 5; > - } else { > + } else if (strcmp(tokens[t0 + 1], "qinq_pppoe") =3D=3D 0) > + p.encap.encap_mask =3D > + 1LLU << > RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE; > + else { > snprintf(out, out_size, MSG_ARG_MISMATCH, > "encap"); > return; > } > - Please put back this blank line. > p.action_mask |=3D 1LLU << RTE_TABLE_ACTION_ENCAP; > t0 +=3D 2 + n_extra_tokens; > } /* encap */ > @@ -3391,6 +3393,43 @@ parse_table_action_encap(char **tokens, > return 1 + 9; > } >=20 > + /* qinq_pppoe */ > + if (n_tokens && (strcmp(tokens[0], "qinq_pppoe") =3D=3D 0)) { > + uint32_t svlan_pcp, svlan_dei, svlan_vid; > + uint32_t cvlan_pcp, cvlan_dei, cvlan_vid; > + > + if ((n_tokens < 10) || > + parse_mac_addr(tokens[1], > + &a->encap.qinq_pppoe.ether.da) || > + parse_mac_addr(tokens[2], > + &a->encap.qinq_pppoe.ether.sa) || > + parser_read_uint32(&svlan_pcp, tokens[3]) || > + (svlan_pcp > 0x7) || > + parser_read_uint32(&svlan_dei, tokens[4]) || > + (svlan_dei > 0x1) || > + parser_read_uint32(&svlan_vid, tokens[5]) || > + (svlan_vid > 0xFFF) || > + parser_read_uint32(&cvlan_pcp, tokens[6]) || > + (cvlan_pcp > 0x7) || > + parser_read_uint32(&cvlan_dei, tokens[7]) || > + (cvlan_dei > 0x1) || > + parser_read_uint32(&cvlan_vid, tokens[8]) || > + (cvlan_vid > 0xFFF) || > + parser_read_uint16(&a- > >encap.qinq_pppoe.pppoe.session_id, > + tokens[9])) > + return 0; > + > + a->encap.qinq_pppoe.svlan.pcp =3D svlan_pcp & 0x7; > + a->encap.qinq_pppoe.svlan.dei =3D svlan_dei & 0x1; > + a->encap.qinq_pppoe.svlan.vid =3D svlan_vid & 0xFFF; > + a->encap.qinq_pppoe.cvlan.pcp =3D cvlan_pcp & 0x7; > + a->encap.qinq_pppoe.cvlan.dei =3D cvlan_dei & 0x1; > + a->encap.qinq_pppoe.cvlan.vid =3D cvlan_vid & 0xFFF; > + a->encap.type =3D RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE; > + a->action_mask |=3D 1 << RTE_TABLE_ACTION_ENCAP; > + return 1 + 10; > + } > + Please add this new encap in the cmd_table_action_profile_help string, as w= ell in the comment describing the table action options (search for "table_a= ction ::=3D ") in this file. > /* mpls */ > if (n_tokens && (strcmp(tokens[0], "mpls") =3D=3D 0)) { > uint32_t label, tc, ttl; > diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h > index c2c5e249f..212ead64a 100644 > --- a/lib/librte_net/rte_ether.h > +++ b/lib/librte_net/rte_ether.h > @@ -300,6 +300,7 @@ struct vxlan_hdr { > #define ETHER_TYPE_ARP 0x0806 /**< Arp Protocol. */ > #define ETHER_TYPE_RARP 0x8035 /**< Reverse Arp Protocol. */ > #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */ > +#define ETHER_TYPE_PPPoE 0x8864 /**< PPPoE Session Stage */ Please add both PPPoE session and PPPoE discovery ethertypes, and call them= accordingly. Please keep the existing naming convention, i.e. keep names a= ll upper case for the purpose of these macros: PPPOE_DISCOVERY and PPPOE_SE= SSION (as opposed to lover case "o" in PPPoE). > #define ETHER_TYPE_QINQ 0x88A8 /**< IEEE 802.1ad QinQ tagging. */ > #define ETHER_TYPE_ETAG 0x893F /**< IEEE 802.1BR E-Tag. */ > #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time > Protocol. */ > diff --git a/lib/librte_pipeline/rte_table_action.c > b/lib/librte_pipeline/rte_table_action.c > index 7c7c8dd82..78cc7a7a2 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__)); >=20 > +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); >=20 > + 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; >=20 > + case RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE: > + return 0; > + > default: > return -EINVAL; > } > @@ -676,6 +690,38 @@ encap_qinq_apply(void *data, > return 0; > } >=20 > +static int > +encap_qinq_pppoe_apply(void *data, > + struct rte_table_action_encap_params *p) > +{ > + struct encap_qinq_pppoe_data *d =3D 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 =3D rte_htons(ETHER_TYPE_VLAN); > + > + /* SVLAN */ > + d->svlan.vlan_tci =3D rte_htons(VLAN(p->qinq.svlan.pcp, > + p->qinq.svlan.dei, > + p->qinq.svlan.vid)); > + d->svlan.eth_proto =3D rte_htons(ETHER_TYPE_VLAN); > + > + /* CVLAN */ > + d->cvlan.vlan_tci =3D rte_htons(VLAN(p->qinq.cvlan.pcp, > + p->qinq.cvlan.dei, > + p->qinq.cvlan.vid)); > + d->cvlan.eth_proto =3D rte_htons(ETHER_TYPE_PPPoE); > + > + /* PPPoE and PPP*/ > + d->pppoe_ppp.ver_type_code =3D rte_htons(0x1100); > + d->pppoe_ppp.session_id =3D rte_htons(p- > >qinq_pppoe.pppoe.session_id); > + d->pppoe_ppp.length =3D 0; /* not pre-computed */ > + d->pppoe_ppp.protocol =3D 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); >=20 > + 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; > } >=20 > + case 1LLU << RTE_TABLE_ACTION_ENCAP_QINQ_PPPOE: > + { > + struct encap_qinq_pppoe_data *qinq_pppoe =3D > + encap(ip, data, sizeof(struct > encap_qinq_pppoe_data)); > + qinq_pppoe->pppoe_ppp.length =3D rte_htons(total_length + > 2); > + mbuf->data_off =3D ip_offset - (sizeof(struct rte_mbuf) + > + sizeof(struct encap_qinq_pppoe_data)); > + mbuf->pkt_len =3D mbuf->data_len =3D 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, > }; >=20 > /** Pre-computed Ethernet header fields for encapsulation action. */ > @@ -529,6 +532,16 @@ struct rte_table_action_encap_config { > }; > }; >=20 > +/** 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 { >=20 > /** 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; > }; > }; >=20 > -- > 2.17.1 Thanks, Cristian