From f0f29232f3d5372b0d0db1ec54a949e345fc15e1 Mon Sep 17 00:00:00 2001 From: Yerden Zhumabekov Date: Fri, 10 Feb 2023 13:51:10 +0600 Subject: [PATCH] ethdev/flow: cleanup Signed-off-by: Yerden Zhumabekov --- ethdev/flow/item_vlan.go | 2 +- ethdev/flow/utils.go | 35 ----------------------------------- 2 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 ethdev/flow/utils.go diff --git a/ethdev/flow/item_vlan.go b/ethdev/flow/item_vlan.go index 5482da9..8c2a1f2 100644 --- a/ethdev/flow/item_vlan.go +++ b/ethdev/flow/item_vlan.go @@ -49,7 +49,7 @@ func (item *ItemVlan) Transform(alloc common.Allocator) (unsafe.Pointer, func(un C.set_has_more_vlan(cptr, 0) } - hdr := (*C.struct_rte_vlan_hdr)(off(unsafe.Pointer(cptr), C.ITEM_VLAN_OFF_HDR)) + hdr := (*C.struct_rte_vlan_hdr)(unsafe.Add(unsafe.Pointer(cptr), C.ITEM_VLAN_OFF_HDR)) hdr.vlan_tci = C.ushort(item.TCI) hdr.eth_proto = C.ushort(item.InnerType) return common.TransformPOD(alloc, cptr) diff --git a/ethdev/flow/utils.go b/ethdev/flow/utils.go deleted file mode 100644 index 5f66d1a..0000000 --- a/ethdev/flow/utils.go +++ /dev/null @@ -1,35 +0,0 @@ -package flow - -/* -#include -#include -#include -*/ -import "C" -import ( - "encoding/binary" - "reflect" - "unsafe" -) - -func off(p unsafe.Pointer, d uintptr) unsafe.Pointer { - return unsafe.Pointer(uintptr(p) + d) -} - -func beU16(n uint16, p unsafe.Pointer) { - var d []byte - sh := (*reflect.SliceHeader)(unsafe.Pointer(&d)) - sh.Data = uintptr(p) - sh.Len = 2 - sh.Cap = sh.Len - binary.BigEndian.PutUint16(d, n) -} - -func beU32(n uint32, p unsafe.Pointer) { - var d []byte - sh := (*reflect.SliceHeader)(unsafe.Pointer(&d)) - sh.Data = uintptr(p) - sh.Len = 4 - sh.Cap = sh.Len - binary.BigEndian.PutUint32(d, n) -}