From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2CEEBA0543; Sun, 18 Dec 2022 00:32:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C0AE440A7A; Sun, 18 Dec 2022 00:32:06 +0100 (CET) Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by mails.dpdk.org (Postfix) with ESMTP id 32F9640685 for ; Sun, 18 Dec 2022 00:32:06 +0100 (CET) Received: by mail-wm1-f51.google.com with SMTP id o5-20020a05600c510500b003d21f02fbaaso6456199wms.4 for ; Sat, 17 Dec 2022 15:32:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=+GrcEwugemWCgKh69rQQwe1/fu1EPn8YovhS5kYa1bM=; b=kDqwIaWwvWSVLvVQ+nke0JpF2cwr5DneF2eguiVf0S7vxOTlv7TnsbnEtdVYRZS/OS IB4QkSClRStGykOKyyStWKjeThcUe8LwwY5IXcCkSDqFKLvLuaPx774RyK5Dhtjn18fK OLx2W0rq4HirsYkpUfryHDVcys85Q+osy1OhMqSkzXnOH3zGBT/0cMTwc9RzN8KjOmKd KlFSVOkOizFeRziO4+rApJizY4QeFHkK0Gt+FKr2ff6zCRto9B43o30vo7St07sOzgYV tUIBlr4HIvGTsRyBo5yOrKXNLmkba+LhIjJi5X0Vq2ljx795XiHNsclFWoyyAr5yzMvd ASfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+GrcEwugemWCgKh69rQQwe1/fu1EPn8YovhS5kYa1bM=; b=SSNm4mJMyT/nSOKNpL5ZR1VriB9hEbaukdTiFDj7HopeBOb5+dUmx8vm7yX2iZdmS4 8yCKGa2AcAORQcKrbCzuQ/8pI6LMoyx6qTbNPMkrO56Zlqmum4LYY+WP7uRYqxq/4wGg jiDLCuK35rnYbSIHO0/2eVClaTbFY0XG14oCPd5MM82/AdkJuI5aMAeGhnXN6ernZtk4 vWt6BkyU5v7vi+JBU39eLCgd+KgLgiu9PML9BIoktfwQWb7qm+s/1lumxaYQxuJqQcsz n+jbMGH8F/UnkGJSbgO4jb0kYGikEjYTgv+W5AMADSpsUaA6/glJy45y/xjbIogtT5D/ e8fA== X-Gm-Message-State: ANoB5pl5bmot8rKNkG8KCp6J0PPdnnYBxzv9GzdhCym2OkFRDPkPbhgm jtjuvc//Ew/QLtbLpwEEGC4= X-Google-Smtp-Source: AA0mqf5MfQrUAj2VzDz29HFwW31TFYFa1L5B5GUBYM96rUQdroCGsR9X2o+mg/gHrNoxlMOIYYuvGQ== X-Received: by 2002:a05:600c:1d0e:b0:3d1:fe93:f1d3 with SMTP id l14-20020a05600c1d0e00b003d1fe93f1d3mr27844252wms.36.1671319925672; Sat, 17 Dec 2022 15:32:05 -0800 (PST) Received: from deluminator.localdomain (115-186-134-228.nayatel.pk. [115.186.134.228]) by smtp.gmail.com with ESMTPSA id v2-20020a05600c214200b003cfa81e2eb4sm7097868wml.38.2022.12.17.15.32.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Dec 2022 15:32:05 -0800 (PST) From: Tanzeel-inline To: olivier.matz@6wind.com Cc: dev@dpdk.org, Tanzeel-inline , Tanzeel Ahmed Subject: [PATCH v2 2/2] lib/net: added push MPLS header API Date: Sat, 17 Dec 2022 18:31:58 -0500 Message-Id: <1671319918-44725-1-git-send-email-tanxeel1.ahmed@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1671299771-10261-1-git-send-email-tanxeel1.ahmed@gmail.com> References: <1671299771-10261-1-git-send-email-tanxeel1.ahmed@gmail.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The mpls hdr can't be const because the bs bit is updated by checking ether type. v2: * marked experimental * trailing blanks removed * space after /* and before */ * updated to bracket cuddle style * changed rte_memcpy to memcpy Signed-off-by: Tanzeel Ahmed --- lib/net/rte_mpls.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/net/rte_mpls.h b/lib/net/rte_mpls.h index 6ae72df..5248391 100644 --- a/lib/net/rte_mpls.h +++ b/lib/net/rte_mpls.h @@ -41,21 +41,25 @@ struct rte_mpls_hdr { #define RTE_MPLS_HLEN 4 /**< Length of MPLS header. */ /** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. + * * Insert MPLS header into the packet. - * + * * If it's first MPLS header to be inserted in the packet, * - Updates the ether type. * - Sets the MPLS bottom-of-stack bit to 1. - * + * * @param m * The pointer to the mbuf. * @param mp * The pointer to the MPLS header. * @return - * 0 on success, -1 on error (If no ethernet header exists) + * 0 on success, -1 on error (If no ethernet header exists) */ +__rte_experimental static inline int -rte_mpls_push_over_l2(struct rte_mbuf **m, struct rte_mpls_hdr *mp) +rte_mpls_push_over_l2(struct rte_mbuf **m, struct rte_mpls_hdr *mp) { struct rte_ether_hdr *oh, *nh; @@ -63,7 +67,7 @@ struct rte_mpls_hdr { if (!RTE_MBUF_DIRECT(*m) || rte_mbuf_refcnt_read(*m) > 1) return -EINVAL; - /*Can't insert header if ethernet frame doesn't exist*/ + /* Can't insert header if ethernet frame doesn't exist */ if (rte_pktmbuf_data_len(*m) < RTE_ETHER_HDR_LEN) return -EINVAL; @@ -78,18 +82,16 @@ struct rte_mpls_hdr { mp->tag_msb = rte_cpu_to_be_16(mp->tag_msb); /* If first MPLS header, update ether type and bottom-of-stack bit */ - if (nh->ether_type != rte_cpu_to_be_16(RTE_ETHER_TYPE_MPLS)) - { + if (nh->ether_type != rte_cpu_to_be_16(RTE_ETHER_TYPE_MPLS)) { nh->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_MPLS); mp->bs = 1; - } - else - { + } else { mp->bs = 0; } /* Copy the MPLS header after ethernet frame */ - rte_memcpy(rte_pktmbuf_mtod_offset(*m, char*, sizeof(struct rte_ether_hdr)), mp, RTE_MPLS_HLEN); + memcpy(rte_pktmbuf_mtod_offset(*m, struct rte_mpls_hdr*, + sizeof(struct rte_ether_hdr)), mp, RTE_MPLS_HLEN); (*m)->data_len += RTE_MPLS_HLEN; return 0; -- 1.8.3.1