net/softnic: add rte flow vxlan action support
PATCH 1/1 net/softnic: add rte flow vxlan action support
Added support to handle vxlan action of rte flow rule.
--- drivers/net/softnic/rte_eth_softnic_flow.c | 192 +++++++++++++++++++++ 1 file changed, 192 insertions(+)
drivers/net/softnic/rte_eth_softnic_flow.c +192 -0
@@ -1634,6 +1634,198 @@ flow_rule_action_get(struct pmd_internals *softnic,break ; }/* RTE_FLOW_ACTION_TYPE_METER */ +case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP : + { +const struct rte_flow_action_vxlan_encap *conf = + action->conf; +const struct rte_flow_item *item; +union flow_item spec, mask; +int disabled =0 , status; +size_t size; + +if (conf ==NULL ) +return rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"VXLAN ENCAP: Null configuration" ); + + item = conf->definition; +if (item ==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 =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type !=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 =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type ==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 =rte_ntohs (spec.vlan.tci); + rule_action->encap.vxlan.vlan.pcp = + tci &0x7 ; + rule_action->encap.vxlan.vlan.dei = + tci &0x8 ; + rule_action->encap.vxlan.vlan.vid = + tci &0xfff ; + + item++; + +flow_item_skip_void (&item); + status =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 = +rte_ntohl (spec.ipv4.hdr.src_addr); + rule_action->encap.vxlan.ipv4.da = +rte_ntohl (spec.ipv4.hdr.dst_addr); + rule_action->encap.vxlan.ipv4.dscp = + spec.ipv4.hdr.type_of_service >>2 ; + rule_action->encap.vxlan.ipv4.ttl = + 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 =rte_ntohl (spec.ipv6.hdr.vtc_flow); + rule_action->encap.vxlan.ipv6.flow_label = + vtc_flow >>12 ; + rule_action->encap.vxlan.ipv6.dscp = + (vtc_flow &0x00000fc0 ) >>6 ; + rule_action->encap.vxlan.ipv6.hop_limit = + 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 =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type !=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 = +rte_ntohs (spec.udp.hdr.src_port); + rule_action->encap.vxlan.udp.dp = +rte_ntohs (spec.udp.hdr.dst_port); + + item++; + +/* Check for VXLAN. */ +flow_item_skip_void (&item); + status =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type !=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 = + (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 !=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 =RTE_TABLE_ACTION_ENCAP_VXLAN ; + rule_action->action_mask |=1 <<RTE_TABLE_ACTION_ENCAP ; +break ; + }/* RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP */ +default :return -ENOTSUP ; }
Signature · 1 line
2.17.1
PATCH v2 1/1 net/softnic: add support for flow API vxlan encap action
Added support to handle vxlan encap action of rte flow rule.
--- drivers/net/softnic/rte_eth_softnic_flow.c | 192 +++++++++++++++++++++ 1 file changed, 192 insertions(+)
drivers/net/softnic/rte_eth_softnic_flow.c +192 -0
@@ -1634,6 +1634,198 @@ flow_rule_action_get(struct pmd_internals *softnic,break ; }/* RTE_FLOW_ACTION_TYPE_METER */ +case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP : + { +const struct rte_flow_action_vxlan_encap *conf = + action->conf; +const struct rte_flow_item *item; +union flow_item spec, mask; +int disabled =0 , status; +size_t size; + +if (conf ==NULL ) +return rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"VXLAN ENCAP: Null configuration" ); + + item = conf->definition; +if (item ==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 =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type !=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 =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type ==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 =rte_ntohs (spec.vlan.tci); + rule_action->encap.vxlan.vlan.pcp = + tci &0x7 ; + rule_action->encap.vxlan.vlan.dei = + (tci &0x8 ) >>3 ; + rule_action->encap.vxlan.vlan.vid = + tci &0xfff0 ; + + item++; + +flow_item_skip_void (&item); + status =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 = +rte_ntohl (spec.ipv4.hdr.src_addr); + rule_action->encap.vxlan.ipv4.da = +rte_ntohl (spec.ipv4.hdr.dst_addr); + rule_action->encap.vxlan.ipv4.dscp = + spec.ipv4.hdr.type_of_service >>2 ; + rule_action->encap.vxlan.ipv4.ttl = + 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 =rte_ntohl (spec.ipv6.hdr.vtc_flow); + rule_action->encap.vxlan.ipv6.flow_label = + vtc_flow >>12 ; + rule_action->encap.vxlan.ipv6.dscp = + (vtc_flow &0x00000fc0 ) >>6 ; + rule_action->encap.vxlan.ipv6.hop_limit = + 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 =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type !=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 = +rte_ntohs (spec.udp.hdr.src_port); + rule_action->encap.vxlan.udp.dp = +rte_ntohs (spec.udp.hdr.dst_port); + + item++; + +/* Check for VXLAN. */ +flow_item_skip_void (&item); + status =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type !=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 = + (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 !=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 =RTE_TABLE_ACTION_ENCAP_VXLAN ; + rule_action->action_mask |=1 <<RTE_TABLE_ACTION_ENCAP ; +break ; + }/* RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP */ +default :return -ENOTSUP ; }
Signature · 1 line
2.17.1
Re: [PATCH v2] net/softnic: add support for flow API vxlan encap action
Quoted 105 lines
-----Original Message-----
From: Pattan, Reshma
Sent: Monday, October 15, 2018 3:42 PM
To: [email protected]; Dumitrescu, Cristian <[email protected]>
Cc: Pattan, Reshma <[email protected]>
Subject: [PATCH v2] net/softnic: add support for flow API vxlan encap actionAdded support to handle vxlan encap action of rte flow rule.
Signed-off-by Reshma Pattan <[email protected]>--- drivers/net/softnic/rte_eth_softnic_flow.c | 192 +++++++++++++++++++++ 1 file changed, 192 insertions(+)drivers/net/softnic/rte_eth_softnic_flow.c +29
-0@@ -1634,6 +1634,198 @@ flow_rule_action_get(struct pmd_internals *softnic, break; }/* RTE_FLOW_ACTION_TYPE_METER */ +case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP : + { +const struct rte_flow_action_vxlan_encap *conf = + action->conf; +const struct rte_flow_item *item; +union flow_item spec, mask; +int disabled =0 , status; +size_t size; + +if (conf ==NULL ) +return rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"VXLAN ENCAP: Null configuration" ); + + item = conf->definition; +if (item ==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,drivers/net/softnic/rte_eth_softnic_flow.c +2
-0+NULL , + "VXLAN ENCAP: Encap action notenabled for this table");
drivers/net/softnic/rte_eth_softnic_flow.c +4
-0+ +/* Check for Ether. */ +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item, &spec,&mask,
drivers/net/softnic/rte_eth_softnic_flow.c +10
-0+ &size, &disabled, error); +if (status) +return status; + +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH ) { + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: first encap itemshould be ether");
drivers/net/softnic/rte_eth_softnic_flow.c +3
-0+ } + ether_addr_copy(&spec.eth.dst, + &rule_action-Quoted 1 line
encap.vxlan.ether.da);
drivers/net/softnic/rte_eth_softnic_flow.c +8
-0+ether_addr_copy (&spec.eth.src, + &rule_action->encap.vxlan.ether.sa); + + item++; + +/* Check for VLAN. */ +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item, &spec,&mask,
drivers/net/softnic/rte_eth_softnic_flow.c +9
-0+ &size, &disabled, error); +if (status) +return status; + +if (item->type ==RTE_FLOW_ITEM_TYPE_VLAN ) { +if (!params->encap.vxlan.vlan) + return rte_flow_error_set(error, + ENOTSUP, +
RTE_FLOW_ERROR_TYPE_ITEM,drivers/net/softnic/rte_eth_softnic_flow.c +2
-0+ item, + "VXLAN ENCAP: vlan encapnot supported by table");
drivers/net/softnic/rte_eth_softnic_flow.c flow_rule_action_get(struct pmd_internals *softnic, · line 1711
Quoted 8 lines
drivers/net/softnic/rte_eth_softnic_flow.c +8
-0+ +uint16_t tci =rte_ntohs (spec.vlan.tci); + rule_action->encap.vxlan.vlan.pcp = + tci &0x7 ; + rule_action->encap.vxlan.vlan.dei = + (tci &0x8 ) >>3 ; + rule_action->encap.vxlan.vlan.vid = + tci &0xfff0 ;
rule_action->encap.vxlan.vlan.pcp = tci >> 13; rule_action->encap.vxlan.vlan.dei = (tci >> 12) & 0x1; rule_action->encap.vxlan.vlan.vid = tci & 0xFFF;
Quoted 136 lines
drivers/net/softnic/rte_eth_softnic_flow.c +5
-0+ + item++; + +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item,&spec,
drivers/net/softnic/rte_eth_softnic_flow.c +1
-0+ &mask, &size, &disabled,error);
drivers/net/softnic/rte_eth_softnic_flow.c +7
-0+if (status) +return status; + }else { +if (params->encap.vxlan.vlan) + return rte_flow_error_set(error, + ENOTSUP, +
RTE_FLOW_ERROR_TYPE_ITEM,drivers/net/softnic/rte_eth_softnic_flow.c +2
-0+ item, + "VXLAN ENCAP: expectingvlan encap item");
drivers/net/softnic/rte_eth_softnic_flow.c +23
-0+ } + +/* Check for IPV4/IPV6. */ +switch (item->type) { +case RTE_FLOW_ITEM_TYPE_IPV4 : + { + rule_action->encap.vxlan.ipv4.sa = +rte_ntohl (spec.ipv4.hdr.src_addr); + rule_action->encap.vxlan.ipv4.da = +rte_ntohl (spec.ipv4.hdr.dst_addr); + rule_action->encap.vxlan.ipv4.dscp = + spec.ipv4.hdr.type_of_service >>2 ; + rule_action->encap.vxlan.ipv4.ttl = + 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));drivers/net/softnic/rte_eth_softnic_flow.c +3
-0+ memcpy(&rule_action->encap.vxlan.ipv6.da, + &spec.ipv6.hdr.dst_addr, +sizeof(spec.ipv6.hdr.dst_addr));drivers/net/softnic/rte_eth_softnic_flow.c +15
-0+ vtc_flow =rte_ntohl (spec.ipv6.hdr.vtc_flow); + rule_action->encap.vxlan.ipv6.flow_label = + vtc_flow >>12 ; + rule_action->encap.vxlan.ipv6.dscp = + (vtc_flow &0x00000fc0 ) >>6 ; + rule_action->encap.vxlan.ipv6.hop_limit = + spec.ipv6.hdr.hop_limits; +break ; + } +default : + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: encap item afterether should be ipv4/ipv6");
drivers/net/softnic/rte_eth_softnic_flow.c +7
-0+ } + + item++; + +/* Check for UDP. */ +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item, &spec,&mask,
drivers/net/softnic/rte_eth_softnic_flow.c +10
-0+ &size, &disabled, error); +if (status) +return status; + +if (item->type !=RTE_FLOW_ITEM_TYPE_UDP ) { + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: encap item afteripv4/ipv6 should be udp");
drivers/net/softnic/rte_eth_softnic_flow.c +11
-0+ } + rule_action->encap.vxlan.udp.sp = +rte_ntohs (spec.udp.hdr.src_port); + rule_action->encap.vxlan.udp.dp = +rte_ntohs (spec.udp.hdr.dst_port); + + item++; + +/* Check for VXLAN. */ +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item, &spec,&mask,
drivers/net/softnic/rte_eth_softnic_flow.c +10
-0+ &size, &disabled, error); +if (status) +return status; + +if (item->type !=RTE_FLOW_ITEM_TYPE_VXLAN ) { + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: encap item after udpshould be vxlan");
drivers/net/softnic/rte_eth_softnic_flow.c +17
-0+ } + rule_action->encap.vxlan.vxlan.vni = + (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 !=RTE_FLOW_ITEM_TYPE_END ) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: expecting ENDitem");
drivers/net/softnic/rte_eth_softnic_flow.c +2
-0+ + rule_action->encap.type =
RTE_TABLE_ACTION_ENCAP_VXLAN;drivers/net/softnic/rte_eth_softnic_flow.c +1
-0+ rule_action->action_mask |= 1 <<
RTE_TABLE_ACTION_ENCAP;drivers/net/softnic/rte_eth_softnic_flow.c +3
-1+break ; + }/* RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP */ +default :return -ENOTSUP ; } --2.17.1
Re: [PATCH v2] net/softnic: add support for flow API vxlan encap action
Quoted 171 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Dumitrescu, Cristian
Sent: Monday, October 15, 2018 5:05 PM
To: Pattan, Reshma <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/softnic: add support for flow API vxlan encap actionQuoted 6 lines
-----Original Message-----
From: Pattan, Reshma
Sent: Monday, October 15, 2018 3:42 PM
To: [email protected]; Dumitrescu, Cristian <[email protected]>
Cc: Pattan, Reshma <[email protected]>
Subject: [PATCH v2] net/softnic: add support for flow API vxlan encapaction
Quoted 97 lines
Added support to handle vxlan encap action of rte flow rule.
Signed-off-by Reshma Pattan <[email protected]>--- drivers/net/softnic/rte_eth_softnic_flow.c | 192 +++++++++++++++++++++ 1 file changed, 192 insertions(+)drivers/net/softnic/rte_eth_softnic_flow.c +29
-0@@ -1634,6 +1634,198 @@ flow_rule_action_get(struct pmd_internals *softnic, break; }/* RTE_FLOW_ACTION_TYPE_METER */ +case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP : + { +const struct rte_flow_action_vxlan_encap *conf = + action->conf; +const struct rte_flow_item *item; +union flow_item spec, mask; +int disabled =0 , status; +size_t size; + +if (conf ==NULL ) +return rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"VXLAN ENCAP: Null configuration" ); + + item = conf->definition; +if (item ==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,drivers/net/softnic/rte_eth_softnic_flow.c +2
-0+NULL , + "VXLAN ENCAP: Encap action notenabled for this table");
drivers/net/softnic/rte_eth_softnic_flow.c +4
-0+ +/* Check for Ether. */ +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item, &spec,&mask,
drivers/net/softnic/rte_eth_softnic_flow.c +10
-0+ &size, &disabled, error); +if (status) +return status; + +if (item->type !=RTE_FLOW_ITEM_TYPE_ETH ) { + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: first encap itemshould be ether");
drivers/net/softnic/rte_eth_softnic_flow.c +3
-0+ } + ether_addr_copy(&spec.eth.dst, + &rule_action-Quoted 1 line
encap.vxlan.ether.da);
drivers/net/softnic/rte_eth_softnic_flow.c +8
-0+ether_addr_copy (&spec.eth.src, + &rule_action->encap.vxlan.ether.sa); + + item++; + +/* Check for VLAN. */ +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item, &spec,&mask,
drivers/net/softnic/rte_eth_softnic_flow.c +9
-0+ &size, &disabled, error); +if (status) +return status; + +if (item->type ==RTE_FLOW_ITEM_TYPE_VLAN ) { +if (!params->encap.vxlan.vlan) + return rte_flow_error_set(error, + ENOTSUP, +
RTE_FLOW_ERROR_TYPE_ITEM,drivers/net/softnic/rte_eth_softnic_flow.c +2
-0+ item, + "VXLAN ENCAP: vlan encapnot supported by table");
drivers/net/softnic/rte_eth_softnic_flow.c flow_rule_action_get(struct pmd_internals *softnic, · line 1711
Quoted 8 lines
drivers/net/softnic/rte_eth_softnic_flow.c +8
-0+ +uint16_t tci =rte_ntohs (spec.vlan.tci); + rule_action->encap.vxlan.vlan.pcp = + tci &0x7 ; + rule_action->encap.vxlan.vlan.dei = + (tci &0x8 ) >>3 ; + rule_action->encap.vxlan.vlan.vid = + tci &0xfff0 ;
rule_action->encap.vxlan.vlan.pcp= tci >> 13;rule_action->encap.vxlan.vlan.dei= (tci >> 12) &0x1;rule_action->encap.vxlan.vlan.vid= tci &0xFFF;Quoted 42 lines
drivers/net/softnic/rte_eth_softnic_flow.c +5
-0+ + item++; + +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item,&spec,
drivers/net/softnic/rte_eth_softnic_flow.c +1
-0+ &mask, &size, &disabled,error);
drivers/net/softnic/rte_eth_softnic_flow.c +7
-0+if (status) +return status; + }else { +if (params->encap.vxlan.vlan) + return rte_flow_error_set(error, + ENOTSUP, +
RTE_FLOW_ERROR_TYPE_ITEM,drivers/net/softnic/rte_eth_softnic_flow.c +2
-0+ item, + "VXLAN ENCAP: expectingvlan encap item");
drivers/net/softnic/rte_eth_softnic_flow.c +23
-0+ } + +/* Check for IPV4/IPV6. */ +switch (item->type) { +case RTE_FLOW_ITEM_TYPE_IPV4 : + { + rule_action->encap.vxlan.ipv4.sa = +rte_ntohl (spec.ipv4.hdr.src_addr); + rule_action->encap.vxlan.ipv4.da = +rte_ntohl (spec.ipv4.hdr.dst_addr); + rule_action->encap.vxlan.ipv4.dscp = + spec.ipv4.hdr.type_of_service >>2 ; + rule_action->encap.vxlan.ipv4.ttl = + 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, +
Quoted 8 lines
drivers/net/softnic/rte_eth_softnic_flow.c flow_rule_action_get(struct pmd_internals *softnic, · line 1755
Quoted 8 lines
sizeof(spec.ipv6.hdr.src_addr));drivers/net/softnic/rte_eth_softnic_flow.c +3
-0+ memcpy(&rule_action->encap.vxlan.ipv6.da, + &spec.ipv6.hdr.dst_addr, +sizeof(spec.ipv6.hdr.dst_addr));drivers/net/softnic/rte_eth_softnic_flow.c +3
-0+ vtc_flow =rte_ntohl (spec.ipv6.hdr.vtc_flow); + rule_action->encap.vxlan.ipv6.flow_label = + vtc_flow >>12 ;
rule_action->encap.vxlan.ipv6.flow_label = vtc_flow & 0xFFFFF;
Quoted 2 lines
drivers/net/softnic/rte_eth_softnic_flow.c flow_rule_action_get(struct pmd_internals *softnic, · line 1757
Quoted 2 lines
drivers/net/softnic/rte_eth_softnic_flow.c +2
-0+ rule_action->encap.vxlan.ipv6.dscp = + (vtc_flow &0x00000fc0 ) >>6 ;
rule_action->encap.vxlan.ipv6.dscp = (vtc_flow >> 22) & 0x3F;
Quoted 84 lines
Quoted 84 lines
drivers/net/softnic/rte_eth_softnic_flow.c +10
-0+ rule_action->encap.vxlan.ipv6.hop_limit = + spec.ipv6.hdr.hop_limits; +break ; + } +default : + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: encap item afterether should be ipv4/ipv6");
drivers/net/softnic/rte_eth_softnic_flow.c +7
-0+ } + + item++; + +/* Check for UDP. */ +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item, &spec,&mask,
drivers/net/softnic/rte_eth_softnic_flow.c +10
-0+ &size, &disabled, error); +if (status) +return status; + +if (item->type !=RTE_FLOW_ITEM_TYPE_UDP ) { + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: encap item afteripv4/ipv6 should be udp");
drivers/net/softnic/rte_eth_softnic_flow.c +11
-0+ } + rule_action->encap.vxlan.udp.sp = +rte_ntohs (spec.udp.hdr.src_port); + rule_action->encap.vxlan.udp.dp = +rte_ntohs (spec.udp.hdr.dst_port); + + item++; + +/* Check for VXLAN. */ +flow_item_skip_void (&item); + status = flow_item_proto_preprocess(item, &spec,&mask,
drivers/net/softnic/rte_eth_softnic_flow.c +10
-0+ &size, &disabled, error); +if (status) +return status; + +if (item->type !=RTE_FLOW_ITEM_TYPE_VXLAN ) { + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: encap item after udpshould be vxlan");
drivers/net/softnic/rte_eth_softnic_flow.c +17
-0+ } + rule_action->encap.vxlan.vxlan.vni = + (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 !=RTE_FLOW_ITEM_TYPE_END ) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "VXLAN ENCAP: expecting ENDitem");
drivers/net/softnic/rte_eth_softnic_flow.c +2
-0+ + rule_action->encap.type =
RTE_TABLE_ACTION_ENCAP_VXLAN;drivers/net/softnic/rte_eth_softnic_flow.c +1
-0+ rule_action->action_mask |= 1 <<
RTE_TABLE_ACTION_ENCAP;drivers/net/softnic/rte_eth_softnic_flow.c +3
-1+break ; + }/* RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP */ +default :return -ENOTSUP ; } --2.17.1
PATCH v3 1/1 net/softnic: add support for flow API vxlan encap action
In reply to Reshma PattanAdded support to handle vxlan encap action of rte flow rule.
---
v3: fixed vlan pcp, dei and vid parsing.
fixed ipv6 flow_label and dscp parsing.
--- drivers/net/softnic/rte_eth_softnic_flow.c | 192 +++++++++++++++++++++ 1 file changed, 192 insertions(+)
drivers/net/softnic/rte_eth_softnic_flow.c +192 -0
@@ -1634,6 +1634,198 @@ flow_rule_action_get(struct pmd_internals *softnic,break ; }/* RTE_FLOW_ACTION_TYPE_METER */ +case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP : + { +const struct rte_flow_action_vxlan_encap *conf = + action->conf; +const struct rte_flow_item *item; +union flow_item spec, mask; +int disabled =0 , status; +size_t size; + +if (conf ==NULL ) +return rte_flow_error_set (error, +EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION , + action, +"VXLAN ENCAP: Null configuration" ); + + item = conf->definition; +if (item ==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 =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type !=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 =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type ==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 =rte_ntohs (spec.vlan.tci); + rule_action->encap.vxlan.vlan.pcp = + tci >>13 ; + rule_action->encap.vxlan.vlan.dei = + (tci >>12 ) &0x1 ; + rule_action->encap.vxlan.vlan.vid = + tci &0xfff ; + + item++; + +flow_item_skip_void (&item); + status =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 = +rte_ntohl (spec.ipv4.hdr.src_addr); + rule_action->encap.vxlan.ipv4.da = +rte_ntohl (spec.ipv4.hdr.dst_addr); + rule_action->encap.vxlan.ipv4.dscp = + spec.ipv4.hdr.type_of_service >>2 ; + rule_action->encap.vxlan.ipv4.ttl = + 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 =rte_ntohl (spec.ipv6.hdr.vtc_flow); + rule_action->encap.vxlan.ipv6.flow_label = + vtc_flow &0xfffff ; + rule_action->encap.vxlan.ipv6.dscp = + (vtc_flow >>22 ) &0x3f ; + rule_action->encap.vxlan.ipv6.hop_limit = + 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 =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type !=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 = +rte_ntohs (spec.udp.hdr.src_port); + rule_action->encap.vxlan.udp.dp = +rte_ntohs (spec.udp.hdr.dst_port); + + item++; + +/* Check for VXLAN. */ +flow_item_skip_void (&item); + status =flow_item_proto_preprocess (item, &spec, &mask, + &size, &disabled, error); +if (status) +return status; + +if (item->type !=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 = + (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 !=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 =RTE_TABLE_ACTION_ENCAP_VXLAN ; + rule_action->action_mask |=1 <<RTE_TABLE_ACTION_ENCAP ; +break ; + }/* RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP */ +default :return -ENOTSUP ; }
Signature · 1 line
2.17.1
Dumitrescu, Cristian
AppliedRe: [PATCH v3] net/softnic: add support for flow API vxlan encap action
Quoted 13 lines
-----Original Message-----
From: Pattan, Reshma
Sent: Tuesday, October 16, 2018 3:29 PM
To: [email protected]; Dumitrescu, Cristian <[email protected]>
Cc: Pattan, Reshma <[email protected]>
Subject: [PATCH v3] net/softnic: add support for flow API vxlan encap actionAdded support to handle vxlan encap action of rte flow rule.
Signed-off-by Reshma Pattan <[email protected]>
Quoted 8 lines
---
v3: fixed vlan pcp, dei and vid parsing.
fixed ipv6flow_labeland dscp parsing.--- drivers/net/softnic/rte_eth_softnic_flow.c | 192 +++++++++++++++++++++ 1 file changed, 192 insertions(+)
Applied to next-pipeline tree, thanks!