DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v2 2/2] lib/net: added push MPLS header API
       [not found] <1671299771-10261-1-git-send-email-tanxeel1.ahmed@gmail.com>
@ 2022-12-17 23:31 ` Tanzeel-inline
  2023-02-06  7:31   ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Tanzeel-inline @ 2022-12-17 23:31 UTC (permalink / raw)
  To: olivier.matz; +Cc: dev, Tanzeel-inline, Tanzeel Ahmed

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 <tanzeelahmed713@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 2/2] lib/net: added push MPLS header API
  2022-12-17 23:31 ` [PATCH v2 2/2] lib/net: added push MPLS header API Tanzeel-inline
@ 2023-02-06  7:31   ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2023-02-06  7:31 UTC (permalink / raw)
  To: Tanzeel-inline; +Cc: olivier.matz, dev, Tanzeel Ahmed, ferruh.yigit

18/12/2022 00:31, Tanzeel-inline:
> 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

This patch is a change on top of the v1.
The new version should include all changes.

Also you should explain why you add this function.
I'm not sure it should be inline.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-06  7:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1671299771-10261-1-git-send-email-tanxeel1.ahmed@gmail.com>
2022-12-17 23:31 ` [PATCH v2 2/2] lib/net: added push MPLS header API Tanzeel-inline
2023-02-06  7:31   ` Thomas Monjalon

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).