[API-NEXT,v2,4/4] linux-gen: packet: implement references as copy

Message ID 1487161772-632-5-git-send-email-petri.savolainen@linaro.org
State New
Headers show
Series
  • Packet references as copy
Related show

Commit Message

Petri Savolainen Feb. 15, 2017, 12:29 p.m.
Implement packet references API as packet copy. This is the
simplest way to support the API, as other packet functions
are not affected at all.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
 platform/linux-generic/odp_packet.c | 74 +++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

-- 
2.8.1

Comments

Bill Fischofer Feb. 15, 2017, 2:29 p.m. | #1
I'd still like to see this posted/used for odp-dpdk to give it basic
functional parity with odp-linux in this area.

On Wed, Feb 15, 2017 at 6:29 AM, Petri Savolainen
<petri.savolainen@linaro.org> wrote:
> Implement packet references API as packet copy. This is the

> simplest way to support the API, as other packet functions

> are not affected at all.

>

> Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

> ---

>  platform/linux-generic/odp_packet.c | 74 +++++++++++++++++++++++++++++++++++++

>  1 file changed, 74 insertions(+)

>

> diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c

> index 024f694..9eccb57 100644

> --- a/platform/linux-generic/odp_packet.c

> +++ b/platform/linux-generic/odp_packet.c

> @@ -2221,3 +2221,77 @@ uint64_t odp_packet_seg_to_u64(odp_packet_seg_t hdl)

>  {

>         return _odp_pri(hdl);

>  }

> +

> +odp_packet_t odp_packet_ref_static(odp_packet_t pkt)

> +{

> +       return odp_packet_copy(pkt, odp_packet_pool(pkt));

> +}

> +

> +odp_packet_t odp_packet_ref(odp_packet_t pkt, uint32_t offset)

> +{

> +       odp_packet_t new;

> +       int ret;

> +

> +       new = odp_packet_copy(pkt, odp_packet_pool(pkt));

> +

> +       if (new == ODP_PACKET_INVALID) {

> +               ODP_ERR("copy failed\n");

> +               return ODP_PACKET_INVALID;

> +       }

> +

> +       ret = odp_packet_trunc_head(&new, offset, NULL, NULL);

> +

> +       if (ret < 0) {

> +               ODP_ERR("trunk_head failed\n");

> +               odp_packet_free(new);

> +               return ODP_PACKET_INVALID;

> +       }

> +

> +       return new;

> +}

> +

> +odp_packet_t odp_packet_ref_pkt(odp_packet_t pkt, uint32_t offset,

> +                               odp_packet_t hdr)

> +{

> +       odp_packet_t new;

> +       int ret;

> +

> +       new = odp_packet_copy(pkt, odp_packet_pool(pkt));

> +

> +       if (new == ODP_PACKET_INVALID) {

> +               ODP_ERR("copy failed\n");

> +               return ODP_PACKET_INVALID;

> +       }

> +

> +       if (offset) {

> +               ret = odp_packet_trunc_head(&new, offset, NULL, NULL);

> +

> +               if (ret < 0) {

> +                       ODP_ERR("trunk_head failed\n");

> +                       odp_packet_free(new);

> +                       return ODP_PACKET_INVALID;

> +               }

> +       }

> +

> +       ret = odp_packet_concat(&hdr, new);

> +

> +       if (ret < 0) {

> +               ODP_ERR("concat failed\n");

> +               odp_packet_free(new);

> +               return ODP_PACKET_INVALID;

> +       }

> +

> +       return hdr;

> +}

> +

> +int odp_packet_has_ref(odp_packet_t pkt)

> +{

> +       (void)pkt;

> +

> +       return 0;

> +}

> +

> +uint32_t odp_packet_unshared_len(odp_packet_t pkt)

> +{

> +       return odp_packet_len(pkt);

> +}

> --

> 2.8.1

>
Savolainen, Petri (Nokia - FI/Espoo) Feb. 15, 2017, 2:35 p.m. | #2
> -----Original Message-----

> From: Bill Fischofer [mailto:bill.fischofer@linaro.org]

> Sent: Wednesday, February 15, 2017 4:29 PM

> To: Petri Savolainen <petri.savolainen@linaro.org>

> Cc: lng-odp-forward <lng-odp@lists.linaro.org>

> Subject: Re: [lng-odp] [API-NEXT PATCH v2 4/4] linux-gen: packet:

> implement references as copy

> 

> I'd still like to see this posted/used for odp-dpdk to give it basic

> functional parity with odp-linux in this area.


I think it's better to upgrade odp-dpdk in order from odp-linux master. There's again quite big gap between odp-linux and odp-dpdk. So, first this into api-next and master, and then from there to odp-dpdk.

-Petri

Patch hide | download patch | download mbox

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 024f694..9eccb57 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2221,3 +2221,77 @@  uint64_t odp_packet_seg_to_u64(odp_packet_seg_t hdl)
 {
 	return _odp_pri(hdl);
 }
+
+odp_packet_t odp_packet_ref_static(odp_packet_t pkt)
+{
+	return odp_packet_copy(pkt, odp_packet_pool(pkt));
+}
+
+odp_packet_t odp_packet_ref(odp_packet_t pkt, uint32_t offset)
+{
+	odp_packet_t new;
+	int ret;
+
+	new = odp_packet_copy(pkt, odp_packet_pool(pkt));
+
+	if (new == ODP_PACKET_INVALID) {
+		ODP_ERR("copy failed\n");
+		return ODP_PACKET_INVALID;
+	}
+
+	ret = odp_packet_trunc_head(&new, offset, NULL, NULL);
+
+	if (ret < 0) {
+		ODP_ERR("trunk_head failed\n");
+		odp_packet_free(new);
+		return ODP_PACKET_INVALID;
+	}
+
+	return new;
+}
+
+odp_packet_t odp_packet_ref_pkt(odp_packet_t pkt, uint32_t offset,
+				odp_packet_t hdr)
+{
+	odp_packet_t new;
+	int ret;
+
+	new = odp_packet_copy(pkt, odp_packet_pool(pkt));
+
+	if (new == ODP_PACKET_INVALID) {
+		ODP_ERR("copy failed\n");
+		return ODP_PACKET_INVALID;
+	}
+
+	if (offset) {
+		ret = odp_packet_trunc_head(&new, offset, NULL, NULL);
+
+		if (ret < 0) {
+			ODP_ERR("trunk_head failed\n");
+			odp_packet_free(new);
+			return ODP_PACKET_INVALID;
+		}
+	}
+
+	ret = odp_packet_concat(&hdr, new);
+
+	if (ret < 0) {
+		ODP_ERR("concat failed\n");
+		odp_packet_free(new);
+		return ODP_PACKET_INVALID;
+	}
+
+	return hdr;
+}
+
+int odp_packet_has_ref(odp_packet_t pkt)
+{
+	(void)pkt;
+
+	return 0;
+}
+
+uint32_t odp_packet_unshared_len(odp_packet_t pkt)
+{
+	return odp_packet_len(pkt);
+}