github.com/vishvananda/netlink@v1.3.0/xdp_linux.go (about) 1 package netlink 2 3 import ( 4 "bytes" 5 "fmt" 6 ) 7 8 const ( 9 xdrDiagUmemLen = 8 + 8*4 10 xdrDiagStatsLen = 6 * 8 11 ) 12 13 func (x *XDPDiagUmem) deserialize(b []byte) error { 14 if len(b) < xdrDiagUmemLen { 15 return fmt.Errorf("XDP umem diagnosis data short read (%d); want %d", len(b), xdrDiagUmemLen) 16 } 17 18 rb := bytes.NewBuffer(b) 19 x.Size = native.Uint64(rb.Next(8)) 20 x.ID = native.Uint32(rb.Next(4)) 21 x.NumPages = native.Uint32(rb.Next(4)) 22 x.ChunkSize = native.Uint32(rb.Next(4)) 23 x.Headroom = native.Uint32(rb.Next(4)) 24 x.Ifindex = native.Uint32(rb.Next(4)) 25 x.QueueID = native.Uint32(rb.Next(4)) 26 x.Flags = native.Uint32(rb.Next(4)) 27 x.Refs = native.Uint32(rb.Next(4)) 28 29 return nil 30 } 31 32 func (x *XDPDiagStats) deserialize(b []byte) error { 33 if len(b) < xdrDiagStatsLen { 34 return fmt.Errorf("XDP diagnosis statistics short read (%d); want %d", len(b), xdrDiagStatsLen) 35 } 36 37 rb := bytes.NewBuffer(b) 38 x.RxDropped = native.Uint64(rb.Next(8)) 39 x.RxInvalid = native.Uint64(rb.Next(8)) 40 x.RxFull = native.Uint64(rb.Next(8)) 41 x.FillRingEmpty = native.Uint64(rb.Next(8)) 42 x.TxInvalid = native.Uint64(rb.Next(8)) 43 x.TxRingEmpty = native.Uint64(rb.Next(8)) 44 45 return nil 46 }