From: Hyong Youb Kim <hyonkim@cisco.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, Hyong Youb Kim <hyonkim@cisco.com>,
stable@dpdk.org, John Daley <johndale@cisco.com>
Subject: [dpdk-dev] [PATCH 5/6] net/enic: generate VXLAN source port if it is zero in template
Date: Wed, 9 Sep 2020 07:00:05 -0700 [thread overview]
Message-ID: <20200909140006.23788-6-hyonkim@cisco.com> (raw)
In-Reply-To: <20200909140006.23788-1-hyonkim@cisco.com>
When VXLAN source port in the template is zero, the adapter is
expected to generate a value based on the inner packet flow, when it
performs encapsulation. Flow Manager in the VIC adapter currently
lacks such ability. So, generate a random port when creating a flow if
the port is zero, to avoid transmitting packets with source port 0.
Fixes: ea7768b5bba8 ("net/enic: add flow implementation based on Flow Manager API")
Cc: stable@dpdk.org
Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
Reviewed-by: John Daley <johndale@cisco.com>
---
drivers/net/enic/enic_fm_flow.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c
index a350b29a3..7eec8e6eb 100644
--- a/drivers/net/enic/enic_fm_flow.c
+++ b/drivers/net/enic/enic_fm_flow.c
@@ -978,6 +978,17 @@ enic_fm_copy_vxlan_decap(struct enic_flowman *fm,
return enic_fm_append_action_op(fm, &fm_op, error);
}
+/* Generate a reasonable source port number */
+static uint16_t
+gen_src_port(void)
+{
+ /* Min/max below are the default values in OVS-DPDK and Linux */
+ uint16_t p = rte_rand();
+ p = RTE_MAX(p, 32768);
+ p = RTE_MIN(p, 61000);
+ return rte_cpu_to_be_16(p);
+}
+
/* VXLAN encap is done via flowman compound action */
static int
enic_fm_copy_vxlan_encap(struct enic_flowman *fm,
@@ -986,6 +997,7 @@ enic_fm_copy_vxlan_encap(struct enic_flowman *fm,
{
struct fm_action_op fm_op;
struct rte_ether_hdr *eth;
+ struct rte_udp_hdr *udp;
uint16_t *ethertype;
void *template;
uint8_t off;
@@ -1084,8 +1096,17 @@ enic_fm_copy_vxlan_encap(struct enic_flowman *fm,
off + offsetof(struct rte_udp_hdr, dgram_len);
fm_op.encap.len2_delta =
sizeof(struct rte_udp_hdr) + sizeof(struct rte_vxlan_hdr);
+ udp = (struct rte_udp_hdr *)template;
append_template(&template, &off, item->spec,
sizeof(struct rte_udp_hdr));
+ /*
+ * Firmware does not hash/fill source port yet. Generate a
+ * random port, as there is *usually* one rte_flow for the
+ * given inner packet stream (i.e. a single stream has one
+ * random port).
+ */
+ if (udp->src_port == 0)
+ udp->src_port = gen_src_port();
item++;
flow_item_skip_void(&item);
--
2.26.2
next prev parent reply other threads:[~2020-09-09 14:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 14:00 [dpdk-dev] [PATCH 0/6] net/enic: minor updates to flow implementation Hyong Youb Kim
2020-09-09 14:00 ` [dpdk-dev] [PATCH 1/6] net/enic: remove obsolete code Hyong Youb Kim
2020-09-09 14:00 ` [dpdk-dev] [PATCH 2/6] net/enic: support egress PORT_ID action Hyong Youb Kim
2020-09-09 14:00 ` [dpdk-dev] [PATCH 3/6] net/enic: support priorities for TCAM flows Hyong Youb Kim
2020-09-09 14:00 ` [dpdk-dev] [PATCH 4/6] net/enic: ignore vlan inner type when it is zero Hyong Youb Kim
2020-09-09 14:00 ` Hyong Youb Kim [this message]
2020-09-09 14:00 ` [dpdk-dev] [PATCH 6/6] net/enic: support VXLAN decap action combined with VLAN pop Hyong Youb Kim
2020-09-21 16:12 ` [dpdk-dev] [PATCH 0/6] net/enic: minor updates to flow implementation Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200909140006.23788-6-hyonkim@cisco.com \
--to=hyonkim@cisco.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=johndale@cisco.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).