From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 867F33256 for ; Mon, 15 Oct 2018 18:05:14 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Oct 2018 09:05:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,385,1534834800"; d="scan'208";a="99369060" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by fmsmga001.fm.intel.com with ESMTP; 15 Oct 2018 09:05:11 -0700 Received: from irsmsx107.ger.corp.intel.com ([169.254.10.56]) by IRSMSX104.ger.corp.intel.com ([169.254.5.213]) with mapi id 14.03.0319.002; Mon, 15 Oct 2018 17:05:11 +0100 From: "Dumitrescu, Cristian" To: "Pattan, Reshma" , "dev@dpdk.org" Thread-Topic: [PATCH v2] net/softnic: add support for flow API vxlan encap action Thread-Index: AQHUZJU3NSe+Z52SFE60Knt05JKH5KUgd8+g Date: Mon, 15 Oct 2018 16:05:10 +0000 Message-ID: <3EB4FA525960D640B5BDFFD6A3D891268E7D9C68@IRSMSX107.ger.corp.intel.com> References: <1539358441-8070-1-git-send-email-reshma.pattan@intel.com> <1539614504-29090-1-git-send-email-reshma.pattan@intel.com> In-Reply-To: <1539614504-29090-1-git-send-email-reshma.pattan@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWJjOGFkMDEtZGMyNy00YzliLTk1ODctZjNkMDg2NTljOGYzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiT0hhUHFNQXQrV3h4U0NVbVJHM2REaWlPRnkrS1pESjFMOWxSdmlzUDVMUVpCK3dhU2lQSTFpNkI2VDRzaUh3NCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] net/softnic: add support for flow API vxlan encap 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, 15 Oct 2018 16:05:15 -0000 > -----Original Message----- > From: Pattan, Reshma > Sent: Monday, October 15, 2018 3:42 PM > To: dev@dpdk.org; Dumitrescu, Cristian > Cc: Pattan, Reshma > Subject: [PATCH v2] net/softnic: add support for flow API vxlan encap act= ion >=20 > Added support to handle vxlan encap action of rte flow rule. >=20 > Signed-off-by: Reshma Pattan > Acked-by: Dumitrescu Cristian > --- > drivers/net/softnic/rte_eth_softnic_flow.c | 192 > +++++++++++++++++++++ > 1 file changed, 192 insertions(+) >=20 > diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c > b/drivers/net/softnic/rte_eth_softnic_flow.c > index 23ef32969..3a17046b4 100644 > --- a/drivers/net/softnic/rte_eth_softnic_flow.c > +++ b/drivers/net/softnic/rte_eth_softnic_flow.c > @@ -1634,6 +1634,198 @@ flow_rule_action_get(struct pmd_internals > *softnic, > break; > } /* RTE_FLOW_ACTION_TYPE_METER */ >=20 > + case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: > + { > + const struct rte_flow_action_vxlan_encap *conf =3D > + action->conf; > + const struct rte_flow_item *item; > + union flow_item spec, mask; > + int disabled =3D 0, status; > + size_t size; > + > + if (conf =3D=3D NULL) > + return rte_flow_error_set(error, > + EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > + action, > + "VXLAN ENCAP: Null configuration"); > + > + item =3D conf->definition; > + if (item =3D=3D NULL) > + return rte_flow_error_set(error, > + EINVAL, > + RTE_FLOW_ERROR_TYPE_ACTION, > + action, > + "VXLAN ENCAP: Null configuration > definition"); > + > + if (!(params->action_mask & > + (1LLU << > RTE_TABLE_ACTION_ENCAP))) > + return rte_flow_error_set(error, > + EINVAL, > + > RTE_FLOW_ERROR_TYPE_UNSPECIFIED, > + NULL, > + "VXLAN ENCAP: Encap action not > enabled for this table"); > + > + /* Check for Ether. */ > + flow_item_skip_void(&item); > + status =3D flow_item_proto_preprocess(item, &spec, > &mask, > + &size, &disabled, error); > + if (status) > + return status; > + > + if (item->type !=3D RTE_FLOW_ITEM_TYPE_ETH) { > + return rte_flow_error_set(error, > + EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "VXLAN ENCAP: first encap item > should be ether"); > + } > + ether_addr_copy(&spec.eth.dst, > + &rule_action- > >encap.vxlan.ether.da); > + ether_addr_copy(&spec.eth.src, > + &rule_action->encap.vxlan.ether.sa); > + > + item++; > + > + /* Check for VLAN. */ > + flow_item_skip_void(&item); > + status =3D flow_item_proto_preprocess(item, &spec, > &mask, > + &size, &disabled, error); > + if (status) > + return status; > + > + if (item->type =3D=3D RTE_FLOW_ITEM_TYPE_VLAN) { > + if (!params->encap.vxlan.vlan) > + return rte_flow_error_set(error, > + ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "VXLAN ENCAP: vlan encap > not supported by table"); > + > + uint16_t tci =3D rte_ntohs(spec.vlan.tci); > + rule_action->encap.vxlan.vlan.pcp =3D > + tci & 0x7; > + rule_action->encap.vxlan.vlan.dei =3D > + (tci & 0x8) >> 3; > + rule_action->encap.vxlan.vlan.vid =3D > + tci & 0xfff0; rule_action->encap.vxlan.vlan.pcp =3D tci >> 13; rule_action->encap.vxlan.vlan.dei =3D (tci >> 12) & 0x1; rule_action->encap.vxlan.vlan.vid =3D tci & 0xFFF; > + > + item++; > + > + flow_item_skip_void(&item); > + status =3D flow_item_proto_preprocess(item, > &spec, > + &mask, &size, &disabled, > error); > + if (status) > + return status; > + } else { > + if (params->encap.vxlan.vlan) > + return rte_flow_error_set(error, > + ENOTSUP, > + > RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "VXLAN ENCAP: expecting > vlan encap item"); > + } > + > + /* Check for IPV4/IPV6. */ > + switch (item->type) { > + case RTE_FLOW_ITEM_TYPE_IPV4: > + { > + rule_action->encap.vxlan.ipv4.sa =3D > + rte_ntohl(spec.ipv4.hdr.src_addr); > + rule_action->encap.vxlan.ipv4.da =3D > + rte_ntohl(spec.ipv4.hdr.dst_addr); > + rule_action->encap.vxlan.ipv4.dscp =3D > + spec.ipv4.hdr.type_of_service >> 2; > + rule_action->encap.vxlan.ipv4.ttl =3D > + spec.ipv4.hdr.time_to_live; > + break; > + } > + case RTE_FLOW_ITEM_TYPE_IPV6: > + { > + uint32_t vtc_flow; > + > + memcpy(&rule_action->encap.vxlan.ipv6.sa, > + &spec.ipv6.hdr.src_addr, > + > sizeof(spec.ipv6.hdr.src_addr)); > + memcpy(&rule_action->encap.vxlan.ipv6.da, > + &spec.ipv6.hdr.dst_addr, > + > sizeof(spec.ipv6.hdr.dst_addr)); > + vtc_flow =3D rte_ntohl(spec.ipv6.hdr.vtc_flow); > + rule_action->encap.vxlan.ipv6.flow_label =3D > + vtc_flow >> 12; > + rule_action->encap.vxlan.ipv6.dscp =3D > + (vtc_flow & 0x00000fc0) >> 6; > + rule_action->encap.vxlan.ipv6.hop_limit =3D > + spec.ipv6.hdr.hop_limits; > + break; > + } > + default: > + return rte_flow_error_set(error, > + EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "VXLAN ENCAP: encap item after > ether should be ipv4/ipv6"); > + } > + > + item++; > + > + /* Check for UDP. */ > + flow_item_skip_void(&item); > + status =3D flow_item_proto_preprocess(item, &spec, > &mask, > + &size, &disabled, error); > + if (status) > + return status; > + > + if (item->type !=3D RTE_FLOW_ITEM_TYPE_UDP) { > + return rte_flow_error_set(error, > + EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "VXLAN ENCAP: encap item after > ipv4/ipv6 should be udp"); > + } > + rule_action->encap.vxlan.udp.sp =3D > + rte_ntohs(spec.udp.hdr.src_port); > + rule_action->encap.vxlan.udp.dp =3D > + rte_ntohs(spec.udp.hdr.dst_port); > + > + item++; > + > + /* Check for VXLAN. */ > + flow_item_skip_void(&item); > + status =3D flow_item_proto_preprocess(item, &spec, > &mask, > + &size, &disabled, error); > + if (status) > + return status; > + > + if (item->type !=3D RTE_FLOW_ITEM_TYPE_VXLAN) { > + return rte_flow_error_set(error, > + EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "VXLAN ENCAP: encap item after udp > should be vxlan"); > + } > + rule_action->encap.vxlan.vxlan.vni =3D > + (spec.vxlan.vni[0] << 16U | > + spec.vxlan.vni[1] << 8U > + | spec.vxlan.vni[2]); > + > + item++; > + > + /* Check for END. */ > + flow_item_skip_void(&item); > + > + if (item->type !=3D RTE_FLOW_ITEM_TYPE_END) > + return rte_flow_error_set(error, > + EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "VXLAN ENCAP: expecting END > item"); > + > + rule_action->encap.type =3D > RTE_TABLE_ACTION_ENCAP_VXLAN; > + rule_action->action_mask |=3D 1 << > RTE_TABLE_ACTION_ENCAP; > + break; > + } /* RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP */ > + > default: > return -ENOTSUP; > } > -- > 2.17.1