diff options
author | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2021-06-03 17:38:38 +0000 |
---|---|---|
committer | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2021-06-03 17:38:38 +0000 |
commit | a32eaa3d00beef6bb81e2aadc2088e9a937d1fd0 (patch) | |
tree | 29c5c0daf2e9905578aa0e6732b2de4a68086e6f /lib/libtle_l4p/stream.h | |
parent | 267cf19de5077e395cc05918159a93e63e8c4a11 (diff) |
l4p: add ability to assign user-data to the stream
Add ability for the user to assign user provided data to the stream.
Right now this user provided 64-bit value is passed as a parameter
for lookup4/lookup6 callbacks.
Another change: change interpretation of lookup4()/lookup6() return value:
< 0: error code (existing behaviour).
== 0: success, TLDK will update L3 header src/dst addresses based on
tldk dev values (existing behaviour).
> 0: success, TLDK will not update L3 header src/dst addresses, will
rely on user provided values.
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Change-Id: I32521422e0372d79c4b2781dd6fc9740e4ca93ab
Diffstat (limited to 'lib/libtle_l4p/stream.h')
-rw-r--r-- | lib/libtle_l4p/stream.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/libtle_l4p/stream.h b/lib/libtle_l4p/stream.h index ebefa6c..405f662 100644 --- a/lib/libtle_l4p/stream.h +++ b/lib/libtle_l4p/stream.h @@ -33,6 +33,8 @@ struct tle_stream { uint8_t type; /* TLE_V4 or TLE_V6 */ + uint64_t udata; /* user data associated wih the stream */ + /* Stream address information. */ union l4_ports port; union l4_ports pmsk; @@ -137,10 +139,10 @@ stream_get_dest(struct tle_stream *s, const void *dst_addr, if (s->type == TLE_V4) { d4 = dst_addr; - rc = ctx->prm.lookup4(ctx->prm.lookup4_data, d4, dst); + rc = ctx->prm.lookup4(ctx->prm.lookup4_data, s->udata, d4, dst); } else if (s->type == TLE_V6) { d6 = dst_addr; - rc = ctx->prm.lookup6(ctx->prm.lookup6_data, d6, dst); + rc = ctx->prm.lookup6(ctx->prm.lookup6_data, s->udata, d6, dst); } else rc = -ENOENT; @@ -150,17 +152,19 @@ stream_get_dest(struct tle_stream *s, const void *dst_addr, dev = dst->dev; dst->ol_flags = dev->tx.ol_flags[s->type]; - if (s->type == TLE_V4) { - struct rte_ipv4_hdr *l3h; - l3h = (struct rte_ipv4_hdr *)(dst->hdr + dst->l2_len); - l3h->src_addr = dev->prm.local_addr4.s_addr; - l3h->dst_addr = d4->s_addr; - } else { - struct rte_ipv6_hdr *l3h; - l3h = (struct rte_ipv6_hdr *)(dst->hdr + dst->l2_len); - rte_memcpy(l3h->src_addr, &dev->prm.local_addr6, - sizeof(l3h->src_addr)); - rte_memcpy(l3h->dst_addr, d6, sizeof(l3h->dst_addr)); + if (rc == 0) { + if (s->type == TLE_V4) { + struct rte_ipv4_hdr *l3h; + l3h = (struct rte_ipv4_hdr *)(dst->hdr + dst->l2_len); + l3h->src_addr = dev->prm.local_addr4.s_addr; + l3h->dst_addr = d4->s_addr; + } else { + struct rte_ipv6_hdr *l3h; + l3h = (struct rte_ipv6_hdr *)(dst->hdr + dst->l2_len); + rte_memcpy(l3h->src_addr, &dev->prm.local_addr6, + sizeof(l3h->src_addr)); + rte_memcpy(l3h->dst_addr, d6, sizeof(l3h->dst_addr)); + } } return dev - ctx->dev; |