blobs

package
v7.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package blobs implements OpenBMC IPMI Blob Protocol commands.

This file declares functions that implement the generic blob transfer interface detailed at https://github.com/openbmc/phosphor-ipmi-blobs with IPMI as a transport layer. See https://github.com/openbmc/google-ipmi-i2c for details on OEM commands.

Index

Constants

View Source
const (
	BMC_BLOB_OPEN_FLAG_READ  = 1 << 0
	BMC_BLOB_OPEN_FLAG_WRITE = 1 << 1
)

Flags for blob open command.

View Source
const (
	BMC_BLOB_STATE_OPEN_R       = 1 << 0
	BMC_BLOB_STATE_OPEN_W       = 1 << 1
	BMC_BLOB_STATE_COMMITTING   = 1 << 2
	BMC_BLOB_STATE_COMMITTED    = 1 << 3
	BMC_BLOB_STATE_COMMIT_ERROR = 1 << 4
)

Flags for blob state.

Variables

View Source
var OENMap = map[string][3]uint8{
	"OpenBMC": {0xcf, 0xc2, 0x00},
}

OENMap maps OEM names to a 3 byte OEM number. OENs are typically serialized as the first 3 bytes of a request body.

Functions

This section is empty.

Types

type BlobHandler

type BlobHandler struct {
	IPMI *ipmi.IPMI
}

BlobHandler provides an interface for the blob protocol. IT can be used to call all the blob transfer commands.

func NewBlobHandler

func NewBlobHandler(i *ipmi.IPMI) *BlobHandler

NewBlobHandler takes an IPMI struct, which provides a reference to the IPMI device driver, and returns a BlobHandler.

func (*BlobHandler) BlobClose

func (h *BlobHandler) BlobClose(sid SessionID) error

BlobClose has the BMC mark the specified blob as closed.

It must be called after commit-polling has finished, regardless of the result.

func (*BlobHandler) BlobCommit

func (h *BlobHandler) BlobCommit(sid SessionID, data []int8) error

BlobCommit commits the blob.

Each blob defines its own commit behavior. Optional blob-specific commit data can be provided with |data|.

func (*BlobHandler) BlobDelete

func (h *BlobHandler) BlobDelete(id string) error

BlobDelete deletes a blob if the operation is supported.

This command will fail if there are open sessions for the blob.

func (*BlobHandler) BlobEnumerate

func (h *BlobHandler) BlobEnumerate(index int) (string, error)

BlobEnumerate returns the blob identifier for the given index.

Note that the index for a given blob ID is not expected to be stable long term. Callers are expected to call BlobGetCount, followed by N calls to BlobEnumerate, to collect all blob IDs.

func (*BlobHandler) BlobGetCount

func (h *BlobHandler) BlobGetCount() (int, error)

BlobGetCount returns the number of enumerable blobs available.

func (*BlobHandler) BlobOpen

func (h *BlobHandler) BlobOpen(id string, flags int16) (SessionID, error)

BlobOpen opens a blob referred to by |id| with the given |flags|, and returns a unique session identifier.

The BMC allocates a unique session identifier, and internally maps it to the blob identifier. The sessionId should be used by the rest of the session based commands to operate on the blob. NOTE: the new blob is not serialized and stored until BlobCommit is called.

func (*BlobHandler) BlobRead

func (h *BlobHandler) BlobRead(sid SessionID, offset, size uint32) ([]uint8, error)

BlobRead reads and return the blob data.

|sessionID| returned from BlobOpen gives us the open blob. The byte sequence starts at |offset|, and |size| bytes are read. If there are not enough bytes, return the bytes that are available.

func (*BlobHandler) BlobSessionStat

func (h *BlobHandler) BlobSessionStat(sid SessionID) (*BlobStats, error)

BlobSessionStat command returns the same data as BmcBlobStat.

However, this command operates on sessions, rather than blob IDs. Not all blobs must support this command; this is only useful when session semantics are more useful than raw blob IDs.

func (*BlobHandler) BlobStat

func (h *BlobHandler) BlobStat(id string) (*BlobStats, error)

BlobStat returns statistics about a blob.

|size| is the size of blob in bytes. This may be zero if the blob does not support reading. |state| will be set with OPEN_R, OPEN_W, and/or COMMITTED as appropriate |metadata| is optional blob-specific bytes

func (*BlobHandler) BlobWrite

func (h *BlobHandler) BlobWrite(sid SessionID, offset int32, data []int8) error

BlobWrite writes bytes to the requested blob offset, and returns number of bytes written if success.

|sessionID| returned from BlobOpen gives us the open blob. |data| is bounded by max size of an IPMI packet, which is platform-dependent. If not all of the bytes can be written, this operation will fail.

type BlobStats

type BlobStats struct {
	// contains filtered or unexported fields
}

BlobStats contains statistics for a given blob.

type CRCOption

type CRCOption string

CRCOption is an option for sending/receiving CRCs.

const (
	REQ_CRC     CRCOption = "REQ_CRC"
	RES_CRC     CRCOption = "RES_CRC"
	NO_CRC      CRCOption = "NO_CRC"
	REQ_RES_CRC CRCOption = "REQ_RES_CRC"
)

CRC options

type SessionID

type SessionID uint16

SessionID is a unique identifier for an open blob.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL